elasticsearch 弹性搜索中使用getapi的搜索查询
我使用的是7.4版。 我主要想实现三件事。 我想根据日期范围进行筛选,然后在标题字段中搜索关键字并输出所选字段。下面是我尝试过但不起作用的代码,请帮助
elasticsearch 弹性搜索中使用getapi的搜索查询,
elasticsearch,logstash,elastic-stack,
elasticsearch,Logstash,Elastic Stack,我使用的是7.4版。 我主要想实现三件事。 我想根据日期范围进行筛选,然后在标题字段中搜索关键字并输出所选字段。下面是我尝试过但不起作用的代码,请帮助 POST test/_search { "query": { "filtered": { "query": { "multi_match": { "query": "Market", "fields": [ "title",
POST test/_search
{
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "Market",
"fields": [
"title",
"message"
]
}
},
"filter": {
"range": {
"published": {
"gte": "now-300d/d",
"lt": "now/d"
}
}
}
}
},
"_source": [
"title",
"message",
"published"
]
}
我得到的信息如下
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "no [query] registered for [filtered]",
"line": 3,
"col": 17
}
],
"type": "parsing_exception",
"reason": "no [query] registered for [filtered]",
"line": 3,
"col": 17
},
"status": 400
}
以上是否有其他方法或任何更正?ES 7.4不支持筛选,而不是我们将使用的必须查询
POST <index_name>/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "Market",
"fields": [
"title",
"message"
]
}
},
{
"range": {
"published": {
"gte": "now-300d/d",
"lt": "now/d"
}
}
}
]
}
},
"_source": [
"title",
"message",
"published"
]
}