简体   繁体   English

通过匹配在多值字段中的位置来提高SOLR相关性

[英]Boost SOLR relevancy by position of match in multivalued field

I'm using SOLR 6.2.1, and has the core with multivalued field: 我正在使用SOLR 6.2.1,并且具有多值字段的核心:

<field name="tag_ids" type="ints" required="false"  indexed="true"  stored="true"/>

It allows to search documents by tag id, with query eg tag_ids:12 . 它允许通过标签id搜索文档,并带有查询,例如tag_ids:12 I have tags into this field, sorted by tag relevancy for the document. 我在此字段中有标签,按文档的标签相关性排序。 I want to sort by document tag relevancy. 我想按文档标签的相关性进行排序。

Example - search query tag_ids:12 , documents: 示例-搜索查询tag_ids:12 ,文档:

[
{
   id: 1,
   tag_ids:[1298,43,12,89]
},
{
   id: 2,
   tag_ids:[12,574,1,4356]
},
{
   id: 3,
   tag_ids:[77,12,65]
}
]

Wanting to see documents with order 2,3,1 . 想要查看顺序为2,3,1的文档。

Question : Is it possible to order by position of match in multi-valued field in Apache SOLR? 问题 :是否可以通过Apache SOLR中多值字段中的匹配位置进行排序? May be some hacks or plugins? 可能是一些黑客或插件?

What you need to do is add the weight information for each tag at index time, and your query would work as is. 您需要做的是在索引时间添加每个标签的重量信息,您的查询将按原样运行。

To index the weight with each tag, you have several ways: 要为每个标签编制重量索引,您可以采用以下几种方法:

  1. Try with payloads, here is a complete example for an older version of Solr, here is another. 尝试使用有效负载, 是旧版本Solr的完整示例, 是另一个示例。 You probably would need to modify this samples as Solr apis have changed since then. 从那时起,您可能需要修改此示例,因为Solr api已更改。
  2. Use the know hack of adding N times each tag, in your examples that would look like: 在示例中,使用将每个标记添加N倍的已知技巧:

    [ { id: 1, tag_ids:[1298,1298,1298,1298,43,43,43,12,12,89] }, { id: 2, tag_ids:[12,12,12,12,574,574,1,1,4356] }, { id: 3, tag_ids:[77,77,77,77,12,12,12,65,65] }] [{id:1,tag_ids:[1298,1298,1298,1298,43,43,43,12,12,89]},{id:2,tag_ids:[12,12,12,12,574,574,1,1 ,4356]},{id:3,tag_ids:[77,77,77,77,12,12,12,65,65]}]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM