Lucene.Net 4.8.0

获取全部索引数据


/// <summary>
/// 获取所有索引值
/// </summary>
public static List<dynamic> GetSearchIndexAll()
{
    var reader = DirectoryReader.Open(FSDirectory.Open(new DirectoryInfo(indexDir)));
    var searcher = new IndexSearcher(reader);

    var aList = new List<dynamic>();

    for (var i = 0; i < reader.MaxDoc; i++)
    {
        var dd = searcher.Doc(i);
        dynamic expando = new System.Dynamic.ExpandoObject();
        dd.Fields.ToList().ForEach(item =>
        {
            (expando as ICollection<KeyValuePair<string, object>>).Add(new KeyValuePair<string, object>(item.Name, item.GetStringValue()));
        });
        aList.Add(expando);
    }
    return aList;
}

 

 

 

Lucene.Net 4.8.0

上一篇:node.js安装及环境变量配置


下一篇:thinkphp 5.0报错pcntl_signal() has been disabled for security reasons问题解决