gpt4 book ai didi

ruby-on-rails - 如何为耐嚼的查询找到相应的ES查询?

转载 作者:行者123 更新时间:2023-12-02 23:13:17 24 4
gpt4 key购买 nike

我在Rails应用程序中使用chewy来查询ElasticSearch。
Autocomplete是我的ElasticSearch索引。

AutocompleteIndex.suggest(
suggest: {
text: cleanup_query('query'),
completion: {
field: 'search_suggest',
size: 10,
contexts: {
entity: @contexts
},
fuzzy: { fuzziness: 'AUTO' }
}
}
).suggest

这是我用来查询 Autocomplete数据的耐嚼查询。
反过来,这样的查询,
{:body=>{:suggest=>{:suggest=>{:text=>["9"], :completion=>{:field=>"search_suggest", :size=>10, :contexts=>{:entity=>[{:context=>"All"}]}, :fuzzy=>{:fuzziness=>"AUTO"}}}}}, :index=>["autocomplete"], :type=>[]}

如何获得上述对应的ElasticSearch查询?

最佳答案

要启用ES日志,请在initializers / chewy.rb中设置Chewy.logger.level = :debug

{:body=>{:suggest=>{:suggest=>{:text=>["9"], :completion=>{:field=>"search_suggest", :size=>10, :contexts=>{:entity=>[{:context=>"All"}]}, :fuzzy=>{:fuzziness=>"AUTO"}}}}}, :index=>["autocomplete"], :type=>[]}

上面是格式化的 flex 搜索查询。上面的相应ES查询为:
curl -X GET "localhost:9200/autocomplete/_search?pretty" -H 'Content-Type: application/json' -d'
{
"suggest" : {
"suggest" : {
"text" : ["9"],
"completion": {
"field": "search_suggest",
"size": 10,
"contexts": {
"entity":[{"context": "All"}]
}
}
}
}
}
'

关于ruby-on-rails - 如何为耐嚼的查询找到相应的ES查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58115832/

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