获取全部索引数据
/// <summary>
/// 获取所有索引值
/// </summary>
public static List<dynamic> GetSearchIndexAll()
{
var reader = DirectoryReader.Open(FSDirectory.Open(new DirectoryInfo(indexDir)));
var searcher = new IndexSearcher(reader);
/// 获取所有索引值
/// </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;
}
{
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;
}