gpt4 book ai didi

json - Elasticsearch多个术语可以促进

转载 作者:行者123 更新时间:2023-12-03 01:36:59 24 4
gpt4 key购买 nike

我一直在努力为过去一个小时的多重查询查找正确的格式,有人可以帮助我正确地编写此格式吗?本质上,它是一个可以多次执行以下操作的查询。

这有效:

{
"query": {
"match" : {
"title": {
"query": "brain",
"boost": 2
}
}
}
}

这是我想要达到的目标,但是没有用。在标题中搜索一个正常术语,在标题中优先搜索另外两个术语。
{
"query": {
"match" : {
"title": {
"query": "neuron",
},
"title": {
"query": "brain",
"boost": 2
},
"query": "birdsong",
"boost": 3
}
}
}
}

我想澄清的另一件事是:

In order for ElasticSearch to understand queries like the above from a web application they must be submitted as a Post HTTP request?

最佳答案

您需要像这样发出bool/should查询:

POST index/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"title": {
"query": "neuron"
}
}
},
{
"match": {
"title": {
"query": "brain",
"boost": 2
}
}
},
{
"match": {
"title": {
"query": "birdsong",
"boost": 3
}
}
}
]
}
}
}

发送查询时,GET和POST均被接受。

关于json - Elasticsearch多个术语可以促进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51674205/

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