搜索结果中solr文档的排名或位置 [英] Ranking or position of a solr document in search results

查看:141
本文介绍了搜索结果中solr文档的排名或位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要列出排名(或位置,如您所愿)或每个文档在solr中查询后。我想看到的东西是这样的:

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?

推荐答案

在挖掘源代码后,我现在可以看到每个不同搜索的动态位置。位置函数为 DocIterator 并在子类中实现。然后,我在 ReturnFields 中添加了一个控制块,用于检查fl是否在其中。它的工作方式与分数类似。最后要做的是添加一个像 PositionAugmenter 这样的定制增强类,类似于 ScoreAugmenter 。然后,我完成了:)

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 :)

感谢您为David Faber 提供处理原始XML结果的想法

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

这篇关于搜索结果中solr文档的排名或位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆