Hi Ned.
It's about
        TopDocs topDocs = searcher.search(query, 10);

        for (int i = 0; i < topDocs.scoreDocs.length; i++) {
            MatchesIterator matches = searcher.matches(topDocs.scoreDocs[i].
doc, "fieldName", query);
            while (matches.next()) { ...

This is (almost) how highlighters (like
https://lucene.apache.org/core/9_0_0/highlighter/org/apache/lucene/search/uhighlight/UnifiedHighlighter.html)
work.
In some sort you can get
https://lucene.apache.org/core/7_3_1/core/org/apache/lucene/search/IndexSearcher.html#explain-org.apache.lucene.search.Query-int-


On Mon, Jul 10, 2023 at 12:19 PM nedyalko.zhe...@freelance.de.INVALID
<nedyalko.zhe...@freelance.de.invalid> wrote:

> Hello Mikhail,
>
> Great, thanks for the very fast response! The link that you provided is
> very useful and informative.
>
> Though, I have an understanding issue. After I have searched for a search
> term, I get always TopDocs that represent the found documents. In my
> understanding there is no relation to the found terms. How can I fetch the
> matched terms that were passed by the query object? Then I could fetch the
> term statistics that is anyway provided by the analyzer or indexer.
>
> I've found the MatchesIterator interface and FilterMatchesIterator class
> but was not able to use it.
>
> Thank you!
> Ned
>


-- 
Sincerely yours
Mikhail Khludnev

Reply via email to