elasticsearch - 在Elasticsearch中使用术语查询

标签 elasticsearch elasticsearch-plugin elastic-stack elasticsearch-2.0

我已经从elasticsearch网站下载了一个示例帐户json数据库。 https://www.elastic.co/guide/en/elasticsearch/reference/current/_exploring_your_data.html

我正在尝试在其上进行一些查询。

例如,

curl -XGET 'http://localhost:9200/bank/account/_count?pretty' -d '{
    "query":{
    "filtered":{
    "filter":{
    "bool":{
    "should":[{"term":{"gender":"M"}},{"term":{"age":35}}]
    }
    }
    }
    }
    }'

得到正确的计数输出。

但是,如果我尝试使用以下查询,则不会得到正确的结果。
curl -XGET 'http://localhost:9200/bank/account/_count?pretty' -d '{
"query":{
"filtered":{
"filter":{
"bool":{                        
"should":[{"term":{"gender":"F"}},{"term":{"state":"PA"}}]
}             
}               
}                    
}      
}'

我没有得到正确的结果。查询语法或使用方式有什么问题吗?

任何人都可以在这里帮忙!

最佳答案

搜索时使用小写字母

eg- f not F
    pa not PA

阅读此书可更好地了解ElasticSearch not returning results for terms query against string property

关于elasticsearch - 在Elasticsearch中使用术语查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39592634/

相关文章:

python-3.x - python3 UnicodeEncodeError : 'charmap' codec can't encode characters in position 95-98: character maps to <undefined>

logging - 如何使用 FileBeat 从日志行设置字段

Elasticsearch 空闲存储空间大幅减少

elasticsearch - kopf elasticsearch插件

elasticsearch - 用 bool 过滤器替换OR/AND/NOT过滤器会创建一个难以理解的查询,其中包含太多的级别?

json - 可以将来自SQL查询的数据插入elasticsearch吗?

elasticsearch - Kibana/Elasticsearch 6.8-delete_by_query返回原因 “blocked by: [FORBIDDEN/8/index write (api)];”

elasticsearch - Kibana-缺少报告功能

elasticsearch - 在elasticsearch中搜索空/当前数组

elasticsearch - 如何更改 elk stack 中的日志保留策略?