How to get hit word at lucene.net

When searching using wildcard queries (dir *), how can I get the word that matches the query? The original content is retained in the document.

+2


source to share


1 answer


You can parse the stored content and pass it through the analyzer used for indexing to see what tokens it generated and then check if they match the query. Then you need to query the IOffsetAttribute to find where in the original content the marker originated.

Remember that the actual indexed token can be garbled by the parser as a step in completion, it can also be synonymous or just pure magic.



What you describe is often a step in trying to present a highlighted search result. If so, then there is already a Lucene.Net.Search.Highlight package , part of a tab.

0


source







All Articles