how can I find query hit positions in original contents?
Suppose I have a document collection that I have indexed in Lucene. I submit a query and get hits. Now what I want is to find where in a particular document hit(s) occur(s). I know that I can use the Lucene Highlighting classes to obtain relevant fragments. But how can I find out where exactly these fragments appear in the original contents?
A related question is how to make sure the found fragments are actually very close to the original query? I noticed in my experiments with highlighting that often I would have a multi-word query and it would return fragments that would have only some of these words. But what if I want to make sure I get hits with all the words?
Re: how can I find query hit positions in original contents?
If you are using multi-word query and want document if only its having all words then in query use occurrence 'must'.
It will ensure you that documents having all words you are searching for.
Hope it helps you!