【发布时间】:2021-11-19 09:09:49
【问题描述】:
我有一个模型 Grave,我想在其中查询名称,查询为“Krogness”
我注意到一件事,返回的结果具有相同的分数。 如文档中所述,我将分片数量减少到 1(不走运)。 我什至禁用了拼写错误(运气不好)
下面附上详细的映射和说明。
型号
searchkick word_middle: %i[name plot_number], callbacks: :async, settings: {number_of_shards: 1}
模型 Searchkick 选项
{:word_middle=>[:name, :plot_number],
:callbacks=>:async,
:settings=>{:number_of_shards=>1},
:_type=>
#<Proc:0x00007f53349fcf98@/home/akshayparekh/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/bundler/gems/searchkick-bcd6edc872f2/lib/searchkick/model.rb:17 (lambda)>,
:class_name=>"Grave"}
搜索选项
{:fields=>["name^10", "plot_number"],
:where=>{:grave_status=>[:accepted, :claimed], :hidden=>false},
:operator=>:or,
:page=>"1",
:per_page=>30,
:misspellings=>false,
:debug=>true}
查询
curl http://localhost:9200/graves_development/_search?pretty -H 'Content-Type: application/json' -d '{"query":{"bool":{"must":{"bool":{"should":[{"dis_max":{"queries":[{"match":{"name.analyzed":{"query":"Krogness","boost":100.0,"operator":"or","analyzer":"searchkick_search"}}},{"match":{"name.analyzed":{"query":"Krogness","boost":100.0,"operator":"or","analyzer":"searchkick_search2"}}}]}},{"dis_max":{"queries":[{"match":{"plot_number.analyzed":{"query":"Krogness","boost":10,"operator":"or","analyzer":"searchkick_search"}}},{"match":{"plot_number.analyzed":{"query":"Krogness","boost":10,"operator":"or","analyzer":"searchkick_search2"}}}]}}]}},"filter":[{"terms":{"grave_status":["accepted","claimed"]}},{"term":{"hidden":{"value":false}}}]}},"timeout":"11s","_source":false,"size":30}'
结果
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1275.969,
"hits": [
{
"_index": "graves_development_20210926173013383",
"_type": "_doc",
"_id": "264729",
"_score": 1275.969
},
{
"_index": "graves_development_20210926173013383",
"_type": "_doc",
"_id": "264730",
"_score": 1275.969
}
]
}
}
我有 2 条记录可以重现此问题。
Test Krogness
Test Krog
当我搜索 Krogness 时,它们的分数相同
Searchkick 版本:4.6.1 Elasticsearch 版本:7.14.1
非常感谢任何帮助
【问题讨论】:
标签: ruby-on-rails elasticsearch searchkick