Elasticsearch query fails from Kubernetes pod but successful from curl request

2/7/2019

I have an elasticsearch query which fails when executed via Node app within a kubernetes pod.

Query:

"size":9999,"aggs":{"x":{"terms":{"field":"c_5.number","size":9999,"missing":"-99"},"aggs":{"y1a":{"filter":{"bool":{"must":[{"term":{"c_101.raw":"Pakka"}}]}},"aggs":{"value":{"value_count":{"field":"c_101.raw"}}}},"y1b":{"value_count":{"field":"c_17.raw"}},"y1":{"bucket_script":{"buckets_path":{"a":"y1a.value","b":"y1b"},"script":"(params.a*100)/params.b"}}}}},"query":{"bool":{"must":[{"bool":{"should":[]}},{"bool":{"must":[]}},{"bool":{"must_not":[]}},{"bool":{"filter":[]}}]}}}'

Error:

body: '{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [c_101.raw] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"d6c89881f9b104c94232777f1fd5e64e27ab1843","node":"ivgn9VOcTP6go8NvC3mnMA","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [c_101.raw] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}]},"status":400}' } {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [c_101.raw] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"d6c89881f9b104c94232777f1fd5e64e27ab1843","node":"ivgn9VOcTP6go8NvC3mnMA","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [c_101.raw] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}]},"status":400}

When I throw a curl request, I get the desired output:

curl -XGET http://localhost:9200/d6c89881f9b104c94232777f1fd5e64e27ab1843/latest/_search -d'
{"size":9999,"aggs":{"x":{"terms":{"field":"c_5.number","size":9999,"missing":"-99"},"aggs":{"y1a":{"filter":{"bool":{"must":[{"term":{"c_101.raw":"Pakka"}}]}},"aggs":{"value":{"value_count":{"field":"c_101.raw"}}}},"y1b":{"value_count":{"field":"c_17.raw"}},"y1":{"bucket_script":{"buckets_path":{"a":"y1a.value","b":"y1b"},"script":"(params.a*100)/params.b"}}}}},"query":{"bool":{"must":[{"bool":{"should":[]}},{"bool":{"must":[]}},{"bool":{"must_not":[]}},{"bool":{"filter":[]}}]}}}'

I have been able to run the above query from my remote machine as well, so yes, ES is available to the apps other than localhost network.

Although, I have read about the fieldData enabling but I don't think that is the reason because had it been the case, I could not even run a curl request(I think).

-- Aviral Srivastava
elasticsearch
kubernetes
node.js

0 Answers