{
"query":{
"constant_score": {
"filter": {
"match":{
"request_1":"rent"
}
}
}
},
"aggs": {
"s": {
"terms": {
"field": "serial_number"
}
}
}
}
This is my query which works fine.
I want inside filter.match I want to add another field so that aggregation happens on result returned when two filter has been satisfied.
I am trying to do something like:
{
"query":{
"constant_score": {
"filter": {
"match":{
"request_1":"rent",
"request_2":"check"
}
}
}
}
}
as suggested I've tried
{
"query":{
"constant_score": {
"filter": [
{
"match":{
"request_1":"rent"
}
},
{
"match":{
"request_2":"check"
}
}
]
}
},
"aggs": {
"s": {
"terms": {
"field": "serial_number"
}
}
}
}
which outputs an error:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "unexpected token [START_ARRAY]",
"line": 4,
"col": 17
}
],
"type": "parsing_exception",
"reason": "unexpected token [START_ARRAY]",
"line": 4,
"col": 17
},
"status": 400
}
So that I get aggregation from those who only have "rent" in request_1 field and "check" in request_2 field. How can I accomplish this?