我有SQL查询:
选择标题,来自地理位置的路径,其中标题位于[“ london”,“ france”]且路径类似于“ 000000039%”且日期不是'2019-01-22'偏移量0限制14按标题排序;
如何正确进行ElasticSearch查询?
我这样发出请求,但不起作用:
curl -XGET "http://service-monitoring--elastic:9200/geo/_search?pretty" -H 'Content-Type: application/json' -d'
{
"_source": [
"title",
"path"
],
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{"terms": {"title": ["london", "france"]}},
{"wildcard": {"path": "000000039*"}}
],
"must_not": [
{"terms": {"date": "2019-01-22"}}
]
}
}
}
}
}'
错误
{"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "no [query] registered for [filtered]",
"line" : 8,
"col" : 25
}
],
"type" : "parsing_exception",
"reason" : "no [query] registered for [filtered]",
"line" : 8,
"col" : 25
},
"status" : 400
}
答案 0 :(得分:1)
filtered
查询已弃用很长时间了,建议改用bool
。从ES 5.0开始,现在已经将其删除。
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html
尝试:
{
"_source": [
"title",
"path"
],
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"terms": {
"title": [
"london",
"france"
]
}
},
{
"wildcard": {
"path": "000000039*"
}
}
],
"must_not": [
{
"terms": {
"date": "2019-01-22"
}
}
]
}
}
}
}
}