gpt4 book ai didi

elasticsearch - 应该+ ElasticSearch中的distance_function

转载 作者:行者123 更新时间:2023-12-03 02:11:25 31 4
gpt4 key购买 nike

我正在尝试在Elasticsearch中返回的值中考虑地理位置的接近性。我希望近距离比某些字段(例如legal_name)重要,但比其他字段重要。
从文档看来,当前的方法是使用distance_feature。但是,我创建的应该条件永远不会以任何相关方式改变结果。实际上,如果我删除了must值,则似乎分数是基于更远的距离得出的。即,更高的分数与更远的距离相关。当然,我想要的是让近距离奖励分数。任何关于我可能做错事情的建议都值得赞赏...
(注意-“坐标”字段的类型为geo_point)
简化文件

{
_index: "organizations",
_type: "_doc",
_id: "3",
_version: 9,
_seq_no: 16944,
_primary_term: 5,
found: true,
_source: {
id: 3,
legal_name: "Air Canada",
operating_name: "Air Canada",
...
coordinate: "43.85133,-79.36572",
}
}
询问
{
"from": 0,
"size": 100,
"query": {
"bool": {
"must": [{
"multi_match": {
"query": "Air Canada",
"fields": ["legal_name^7","operating_name^7","interest_areas^4","city^3", "description","state","country"
]
}},
{"term" : { "organization_type.keyword": "Sponsor" }},
{"term" : { "approved" : true }}
],
"should": {
"distance_feature": {
"field": "coordinate",
"pivot": "25km",
"origin": [43.63, -79.3716],
"boost": 5.0
}
}
}
}
}```

最佳答案

最后,我放弃了distance_feature,而是使用了高斯函数。
{
“来自”:0,
“大小”:20,
“查询”:{

"function_score": {
"query": {
"bool": {
"must": [{
"multi_match": {
"query": "national bank",
"fields": ["legal_name^0.7", "operating_name^0.7", "interest_areas^0.4", "city^0.4", "description^0.4", "state^0.1", "country^0.1"]
}},
{"term" : { "organization_type.keyword": "Sponsor" }},
{"term" : { "approved" : true }}
]
}
},
"boost": "1",
"boost_mode": "sum",
"functions": [{
"gauss": {
"coordinate": {
"origin": { "lat": 43.63, "lon": -79.3716 },
"offset": "500km",
"decay": 0.5,
"scale": "100km"
}
},
"weight": 1
}]
}
}
}`

关于elasticsearch - 应该+ ElasticSearch中的distance_function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64598770/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com