简体   繁体   中英

Grouped Search in Lucene.NET

I would like to transfer the following example of a grouped search of the Lucene documentation to .NET. I am using Lucene.NET in version 3.0.3.0:

GroupingSearch groupingSearch = new GroupingSearch("author");
groupingSearch.setGroupSort(groupSort);
groupingSearch.setFillSortFields(fillFields);

if (useCache) {
  // Sets cache in MB
  groupingSearch.setCachingInMB(4.0, true);
}

if (requiredTotalGroupCount) {
  groupingSearch.setAllGroups(true);
}

TermQuery query = new TermQuery(new Term("content", searchTerm));
TopGroups<BytesRef> result = groupingSearch.search(indexSearcher, query, groupOffset, groupLimit);

// Render groupsResult...
if (requiredTotalGroupCount) {
  int totalGroupCount = result.totalGroupCount;
}

As far as I've managed to find out, the grouped search is not implemented in Lucene.NET.

a) Is that correct? b) If yes, what would be the way to go to build a substitute?

If the amount of possible groups is not large you can use Faceted search, it's implemented in Lucene.Net 3.0. https://cwiki.apache.org/confluence/display/LUCENENET/Simple+Faceted+Search The default limitation is 2048 facets (groups). You can increase it but this will increase memory usage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM