如何通过kibana查询Elasticsearch以选择具有字段x的项目x?
例如,我有一个字段 {"a": {"type": "string"}, "b": {"type": "string"}}
的映射,两个文档
{"a": "lalala"}
{"a": "enoheo", "b": "nthtnhnt"}
我想在不知道其b
实际是什么的情况下找到第二个文档。
已经有一段时间了。如果任何人需要更新的答案,文档现在为选择具有一定字段的结果提供此示例。
在查询弦语法中:
场
title
具有任何非编号值:_exists_:title
https://www.elastic.co/guide/en/elasticsearch/reference/current/qurery-dsl-query-query-string-query.html#_field_names
使用"存在的过滤器",例如:
POST /test_index/_search
{
"filter": {
"exists": {
"field": "b"
}
}
}
编辑:如果您需要Lucene查询 - 弦乐查询,则应该这样做:
POST /test_index/_search
{
"query": {
"query_string": {
"query": "b:*"
}
}
}
这是我用来对其进行测试的一些代码:
http://sense.qbox.io/gist/AD336A0888A279BFDACE03E217BF1915ADBF0FE2