I am using Elastic search-1.2.2.
Here I have to do a combination of filter + sort. Need to get to sorted id value with respect to filter
I don't like to use facet since it was deprecated. Query filter doesn't support AND filter,so I tried of mentioning boolFilter and specified it as post filter in searchQueryBuilder. Query:
{
"from": 0,
"size": 10,
"sort": [
{
"display_order": {
"order": "asc"
}
}
],
"post_filter": {
"bool": {
"must": {
"and": {
"filters": [
{
"term": {
"item_ids": ["564279ac-a887-4a0b-99e9-5802b4508747","564279ac-a887-4a0b-99e9-5802b4508447","564279ac-a887-4a0b-99e9-5302b4508747"]
}
}
]
}
}
}
}
}
but this query only filter the record,soting not working here.
whether I am doing any thing wrong?
I think you're overcomplicating the issue -
What do you mean by "not working" - do you get an error?
Can you try this simplified query:
curl -XGET "http://localhost:9200/hubware3/message/_search?pretty" -d'
{
"sort": [
{
"display_order": {"order": "asc"}
}
],
"filter" : {
"terms" : { "item_ids" : ["564279ac-a887-4a0b-99e9-5802b4508747","564279ac-a887-4a0b-99e9-5802b4508447","564279ac-a887-4a0b-99e9-5302b4508747"]}
}
}
}'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.