elasticsearch - Elasticsearch 只查找数值
问题描述
大家,早安!
使用elasticsearch,我可以执行此请求,该请求允许我拥有某个特定的所有配置文件phone_user
,它可以工作:
curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/companyname/projectname/_search?pretty' -d '
{"query":{"bool":{"filter":{"terms":{"phone_user":["33612345678"]}}}}}'
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : null,
"hits" : [
{
"_index" : "companyname",
"_type" : "projectname",
"_id" : "113",
"_score" : null,
"_source" : {
"phone_user" : "33612345678",
"status_user" : "READY",
……
}
}
]
}
}
但是,如果值不再是数字而是文本,我将不再有任何结果:
curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/companyname/projectname/_search?pretty' -d '
{"query":{"bool":{"filter":{"terms":{"status_user":["READY"]}}}}}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
我的映射:
{
"conpanyname" : {
"mappings" : {
"projectname" : {
"properties" : {
"phone_user" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"status_user" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
你以前有没有遇到过这样的问题?
非常感谢!
解决方案
推荐阅读
- javascript - 为什么我在我的 React 应用程序中丢失了登录信息?
- node.js - 在我的测试用例中,我的 console.log 没有输出
- amazon-web-services - Flink - AWS 上的外部检查点
- r - 在 ggplot 中突出显示我的一个折线图
- sql - SQL 正则表达式 substr 模式匹配
- python - 将“in”成员资格分配给变量?
- python - 用 pyarrow 将大熊猫数据框写成镶木地板
- for-loop - 如何使用 Bat 文件在目录中的每个文件夹中创建 txt 文件?
- cadence-workflow - 如何在节奏工作流活动中存储当前光标位置
- javascript - hAxis viewWindow 和 ticks 返回一个错误的图形,但 vAxis 运行良好