Elasticsearch多个术语可以促进 [英] Elasticsearch Multiple Terms to Boost
问题描述
在过去的一个小时里,我一直在尝试为多重增强查询找到正确的格式,有人可以帮助我正确地编写此格式吗?本质上,它是一个可以多次执行以下操作的查询.
i've been trying to find the right format for a mutliple boost query for the last hour, could someone assist me in writing this correctly? essentially it is a single query that can do the below many times.
这有效:
{
"query": {
"match" : {
"title": {
"query": "brain",
"boost": 2
}
}
}
}
这是我要实现的目标,但是没有用.在标题中搜索一个正常术语,在标题中优先搜索另外两个术语.
This is what i am trying to achieve but does not work. One normal term to search in title and two other boosted terms to also prioritise in title.
{
"query": {
"match" : {
"title": {
"query": "neuron",
},
"title": {
"query": "brain",
"boost": 2
},
"query": "birdsong",
"boost": 3
}
}
}
}
我想澄清的另一件事是:
Another thing i'd like to clarify is:
为了使ElasticSearch能够从 Web应用程序,它们必须作为Post HTTP请求提交?
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
查询:
You need to issue a bool/should
query like this:
POST index/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"title": {
"query": "neuron"
}
}
},
{
"match": {
"title": {
"query": "brain",
"boost": 2
}
}
},
{
"match": {
"title": {
"query": "birdsong",
"boost": 3
}
}
}
]
}
}
}
发送查询时,接受GET和POST.
Both GET and POST are accepted when sending a query.
这篇关于Elasticsearch多个术语可以促进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!