Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One of the solutions is to do the following (QUITE A LOT OF CODING - I'm not aware of a shortcut as you need to traverse term positions within documents. There is no built-in functionality to do so via functions, but you also may think of using Payloads somehow).</p> <ol> <li>Create your own query type, extending the basic TermQuery.</li> <li>For TermsQuery the scoring logic boils down to traversing the TermsEnum object created with your term. You can use the DocsAndPositionsEnum to enumerate all the positions of the specific term in each document.</li> <li>I assume you don't care about the Lucene similarity calculation (do you?). Then you may simply return the average position in a specific document as a 'score'</li> <li>The tricky part is to return average information across your set without returning the documents themselves. I would try to use the StatsComponent, which returns basic statistics for a certain field in the result set. I don't know if it can work with a 'score' field, or any other calculated field. If it doesn't, try altering the QueryComponent to calculate the average and set it as a result instead of the documents. If you expect to run this thing within a cluster (distributed search), you would also have to override the distributed query behavior so that you calculate the average from all of the shards.</li> </ol> <p>Perhaps another option is to alter the indexing logic and calculate those averages in analysis stage. If you manage to do so (putting it into payload), you can fetch this information much faster in query time, but it means developing a sophisticated analysis filter.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload