Ranking or position of a solr document in search results

两盒软妹~` 提交于 2019-12-11 04:09:43

问题


I need to list the ranking (or position, as you might prefer) or each document after a query in solr. the thing i wanna see is something like this:

<doc>
    <int name="field1">1</int>
    <str name="someotherfield">blabla</str>
    <int name="position">1</int>
</doc>
<doc>
    <int name="field1">2</int>
    <str name="someotherfield">blabla</str>
    <int name="position">2</int>
</doc>
<doc>
    <int name="field1">3</int>
    <str name="someotherfield">blabla</str>
    <int name="position">3</int>
</doc>

is this possible? or i need to implement or find a plugin?


回答1:


well after digging the source code, I am now able to see dynamic positions for each different search.. I have simply added a position function to DocIterator and implemented in in subclasses. Then I have added a control block in ReturnFields for checking if fl has position in it. It is working in a similar way with score. and the last thing to do was adding a custom augmenter class like PositionAugmenter - similar to ScoreAugmenter. Then I am done :)

thank you for David Faber for giving me idea of dealing with the results of raw XML




回答2:


List a field position (among other things) in results:

...&fl=field1,field2,position

Sort by position

...&sort=position desc 

Refer them here : http://wiki.apache.org/solr/CommonQueryParameters#sort



来源:https://stackoverflow.com/questions/12666521/ranking-or-position-of-a-solr-document-in-search-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!