Ex.
"docs": [
{
"id": "f37914",
"index_id": "some_index",
"field_1": [
{
"Some value",
"boost": 20.
}
]
},
]
如果' field_1'匹配,然后通过相应的“提升”来提升领域。
答案 0 :(得分:1)
例如,如果你想提升文件(并假设价值不匹配,则得分为0)那么你可以这样做:
q:_val_:"if(query($q1), field(boost), 0)"&q1=field_1:"Some Value"
_val_
只是Solr函数查询的一个钩子,query
如果q1
匹配则返回true,field
是一个只返回字段值的简单函数self和if
允许我们将两者结合在一起。
答案 1 :(得分:0)
所以我最终做的是使用lucence payloads和solr 6.6 new DelimitedPayloadTokenFilter功能。
首先,我使用以下配置创建了一个术语字段:
{
"add-field-type": {
"name": "terms",
"stored": "true",
"class": "solr.TextField",
"positionIncrementGap": "100",
"indexAnalyzer": {
"tokenizer": {
"class": "solr.KeywordTokenizerFactory"
},
"filters": [
{
"class": "solr.LowerCaseFilterFactory"
},
{
"class": "solr.DelimitedPayloadTokenFilterFactory",
"encoder": "float",
"delimiter": "|"
}
]
},
"queryAnalyzer": {
"tokenizer": {
"class": "solr.KeywordTokenizerFactory"
},
"filters": [
{
"class": "solr.LowerCaseFilterFactory"
},
{
"class": "solr.SynonymGraphFilterFactory",
"ignoreCase": "true",
"expand": "false",
"tokenizerFactory": "solr.KeywordTokenizerFactory",
"synonyms": "synonyms.txt"
}
]
}
},
"add-field" : {
"name":"terms",
"type":"terms",
"stored": "true",
"multiValued": "true"
}
}
我索引我的文档是这样的:
[
{
"id" : "1",
"terms" : [
"some term|10.0",
"another term|60.0"
]
}
,
{
"id" : "2",
"terms" : [
"some term|11.0",
"another term|21.0"
]
}
]
我使用solr的功能查询支持来查询条件匹配并获取附加的boost有效负载并将其应用于相关性分数:
/solr/payloads/select?indent=on&wt=json&q={!payload_score%20f=ai_terms_wtih_synm_3%20v=$payload_term%20func=max}&fl=id,score&payload_term=some+term