Reputation: 27
I am using version 7.4. I wanna achieve mainly three things. I want to filter as per a date range and then search for a keyword in the "title" field and output selected field. Below is the code I tried but not working, Please help.
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"
]
}
I am getting as below
{
"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
}
Is there any other way or any correction in the above?
Upvotes: 0
Views: 145
Reputation: 555
ES 7.4 not support filtered instead of that we will use must query
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"
]
}
Upvotes: 1