Reputation: 45
In RavenDB < 4, you could get the matched word/sentence from a query/search using the FieldHighlightings class:
FieldHighlightings highlight = null;
hits = session
.Advanced
.DocumentQuery<FAOCRPage>("Standard/Lucene")
.Statistics(out stats)
**.Highlight(x => x.OCR, 50, 5, out highlight)**
.SetHighlighterTags("**", "**")
.Skip(pageNum*pageSize)
.Take(pageSize)
.Search(x => x.OCR, queryStr, escapeQueryOptions: EscapeQueryOptions.RawQuery)
.ToList();
string[] fragments = highlight.GetFragments(hits[0].Id)
And iterate though the highlight variable to get the match text. I RavenDB v4 this class seems to be removed. How can I get the text the was matched in a query/lucene search and not just the document where it was found in?
I.e. if we have the text "This is a small test, they are going nowhere" and searching using wildcard query for "th*", then I would expect the result "this" and "they" and where they occurred in the text.
Is this not possible anymore?
Upvotes: 2
Views: 65
Reputation: 9163
It's not currently possible in v4.0 but it would be possible with v4.1.
(Planned to be released in a few months).
Upvotes: 1