Hi,
I am trying to query a dataset of 6 million records for specific words using Lucene and get back all document where the word occurs together with where it was found. To achieve this, I am using the highlight function.
I can get the highlight to work using the “.ToList()” method, but it only works, when the result set are below 1024 rows and I need all the rows. I am using the following code:
FieldHighlightings highlight = null;
var hits = session
.Advanced
.DocumentQuery<FAOCRPage>("Standard/Lucene")
.Highlight(x => x.OCR, 50, 5, out highlight)
.SetHighlighterTags("**", "**")
.Search(x => x.OCR, queryStr, escapeQueryOptions: EscapeQueryOptions.RawQuery);
List<FAOCRPage> items = new List<FAOCRPage>();
using (var enumerator = session.Advanced.Stream(hits))
{
while (enumerator.MoveNext())
{
var elem = enumerator.Current.Document;
string[] fragments = highlight.GetFragments(elem.Id);
elem.FoundText = String.Join(";", fragments) // Store the fragment(s)
items.Add(elem);
}
}
If I execute this code it will find the results (possible > 1024 rows), but the highlight object does not contain any information of where the word was found. Is the highlight function not supported when streaming results from session.Advanced.Stream. If not supported is there any other way to the get the highlighting of the result?
I am using ravendb build #30037.
Regards
Rune