REST SearchSourceBuilder-Unknowed Named Object


#1

Working with query constrained aggs via SearchSourceBuilder as documented at:

[Java high level rest client: how to deal with aggregations?]

This works within Java, but generates the following error when executed via CURL:

curl -H "Content-Type: application/json" -X POST http://localhost:9200/nashdemog-000001/_search -d @RaceGender.json

{"error":{"root_cause":[{"type":"unknown_named_object_exception","reason":"Unknown BaseAggregationBuilder [bool]","line":1,"col":26}],"type":"unknown_named_object_exception","reason":"Unknown BaseAggregationBuilder [bool]","line":1,"col":26},"status":400}

CURL works correctly if the aggs wrapper is removed.

The query generator wraps everything in a "aggs" tag, as follows below:

{
"aggs": {
"query": {
"bool": {
"filter": [{
"term": {
"ethnic_code_description": {
"value": "Black",
"boost": 1.0
}
}
}, {
"term": {
"gender": {
"value": "M",
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"aggregations": {
"Race": {
"terms": {
"field": "ethnic_code_description",
"size": 5,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [{
"_count": "desc"
}, {
"_key": "asc"
}]
},
"aggregations": {
"Gender": {
"terms": {
"field": "gender",
"size": 3,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [{
"_count": "desc"
}, {
"_key": "asc"
}]
},
"aggregations": {
"Salary": {
"avg": {
"field": "annual_salary"
}
}
}
}
}
}
}
}
}


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.