如果匹配特定字段,是否可以将 solr 文档 int 字段值应用为 boost 值? [英] Is it possible to apply a solr document int field value as boost value if a specific field is matched?

查看:8
本文介绍了如果匹配特定字段,是否可以将 solr 文档 int 字段值应用为 boost 值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ex. 

"docs": [
{
"id": "f37914",
"index_id": "some_index",
"field_1": [
   {
      "Some value",
      "boost": 20.
   }
 ]
},
]

如果field_1"匹配,则通过相应的boost"字段提升.

If 'field_1' is matched, then boost by corresponding 'boost' field.

推荐答案

Boost 什么?文件?具体领域?你可以做任何一个.无论如何,这样做的方法是使用函数查询:https://lucene.apache.org/solr/guide/6_6/function-queries.html#FunctionQueries-AvailableFunctions

Boost what? the document? the specific field? you can do any of them. Anyway the way to do it is to user Function Queries: https://lucene.apache.org/solr/guide/6_6/function-queries.html#FunctionQueries-AvailableFunctions

例如,如果您想提升文档(并假设值不匹配则分数为 0),那么您可以执行以下操作:

For example if you want to boost the document (and assuming if the value doesn't match then the score is 0) then you can do something like that:

q:_val_:"if(query($q1), field(boost), 0)"&q1=field_1:"Some Value"

_val_ 只是 Solr 函数查询的一个钩子,如果 q1 匹配,query 返回 true,field 是一个简单的函数,它只返回字段本身的值,并且 if 允许我们将两者连接在一起.

_val_ is just a hook into Solr function query, query returns true if q1 matches, field is a simple function that just return the value of the field it self and if allows us to join the two together.

这篇关于如果匹配特定字段,是否可以将 solr 文档 int 字段值应用为 boost 值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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