Elasticsearch查询从Kubernetes pod失败,但从curl请求成功

时间:2019-02-07 16:50:28

标签: node.js elasticsearch kubernetes

我有一个Elasticsearch查询,当通过kubernetes容器中的Node app执行时,该查询失败。

查询:

"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":[]}}]}}}'

错误:

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}

当我抛出一个curl请求时,我得到了想要的输出:

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":[]}}]}}}'

我也能够从我的远程计算机上运行上述查询,因此,是的,ES可以用于localhost网络以外的应用。

尽管我已经阅读了有关启用fieldData的信息,但我不认为这是原因,因为在这种情况下,我什至无法运行curl请求(我认为)。

0 个答案:

没有答案