# Check query before sending it to data nodes

**URL:** <https://discuss.elastic.co/t/check-query-before-sending-it-to-data-nodes/103004>\
**Category:** Elasticsearch\
**Created:** [October 6, 2017, 12:30pm UTC](https://discuss.elastic.co/t/check-query-before-sending-it-to-data-nodes/103004 "2017-10-06T12:30:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [October 6, 2017, 12:30pm UTC](https://discuss.elastic.co/t/check-query-before-sending-it-to-data-nodes/103004/1 "2017-10-06T12:30:59Z")

</div>

In a typical cluster, we have a client node and data nodes.

We send query to client node, that dispatch it to data nodes.

Client node should check that the query is good (no parsing error) before sending it to data nodes (and receive the big error message for each shards ^^):

> [2017-10-04 13:29:49,150][DEBUG][action.search] [PAR-X-ESWLB02] [0], node, [P], v[3], s[STARTED], a[id=X]: Failed to execute [org.elasticsearch.action.search.SearchRequest@1f7470f6]  
> RemoteTransportException[[PAR-X-ESDATA03][X:9300][indices:data/read/search[phase/query]]]; nested: SearchParseException[failed to parse search source [{  
> "aggs": {  
> "distinct\_colors": {  
> "terms": {  
> "field.simple": "category",  
> "size": 1000  
> }  
> }  
> }  
> }  
> ]]; nested: SearchParseException[Unknown key for a VALUE\_STRING in [distinct\_colors]: [field.simple].];  
> Caused by: SearchParseException[failed to parse search source [{  
> "aggs": {  
> "distinct\_colors": {  
> "terms": {  
> "field.simple": "category",  
> "size": 1000  
> }  
> }  
> }  
> }  
> ]]; nested: SearchParseException[Unknown key for a VALUE\_STRING in [distinct\_colors]: [field.simple].];  
> at org.elasticsearch.search.SearchService.parseSource(SearchService.java:873)  
> at org.elasticsearch.search.SearchService.createContext(SearchService.java:667)  
> at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633)  
> at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:377)  
> at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:368)  
> at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:365)  
> at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)  
> at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77)  
> at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.doRun(MessageChannelHandler.java:293)  
> at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
> at java.lang.Thread.run(Thread.java:745)  
> Caused by: SearchParseException[Unknown key for a VALUE\_STRING in [distinct\_colors]: [field.simple].]  
> at org.elasticsearch.search.aggregations.bucket.terms.TermsParametersParser.parseSpecial(TermsParametersParser.java:83)  
> at org.elasticsearch.search.aggregations.bucket.terms.AbstractTermsParametersParser.parse(AbstractTermsParametersParser.java:87)  
> at org.elasticsearch.search.aggregations.bucket.terms.TermsParser.parse(TermsParser.java:54)  
> at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:198)  
> at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:103)  
> at org.elasticsearch.search.aggregations.AggregationParseElement.parse(AggregationParseElement.java:60)  
> at org.elasticsearch.search.SearchService.parseSource(SearchService.java:856)  
> ... 12 more

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 3, 2017, 12:31pm UTC](https://discuss.elastic.co/t/check-query-before-sending-it-to-data-nodes/103004/2 "2017-11-03T12:31:11Z")

</div>

Closed on November 3, 2017, 12:31pm UTC

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