Json 弹性搜索词筛选器不工作
这是我的弹性搜索查询,用于获取idJson 弹性搜索词筛选器不工作,json,
elasticsearch,Json,
elasticsearch,这是我的弹性搜索查询,用于获取id curl -XGET localhost:9200/test-index2/business/_search -d' { "query" : { "filtered" : { "query" : { "match_all" : {} }, "filter" : { "term" :
curl -XGET localhost:9200/test-index2/business/_search -d'
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"term" : {
"_id" : "AU6LqK0WCSY7HKQGengx"
}
}
}
}
}'
这是回应的一部分
{"contactNumber": "+1-415-392-3702", "name": "Golden Gate Hotel"}
我有联系电话和姓名
现在,我的第二个查询->我正在使用术语过滤器查询上述联系人号码
curl -XGET localhost:9200/test-index2/business/_search -d'
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"term" : {
"contactNumber" : "+1-415-392-3702"
}
}
}
}
}'
我的点击率0强>
我已经为contactNumber和name字段编制了索引
我做错了什么
我应该会得到完全相同的记录
编辑:
附加联系人号码的映射
{"test-index2":{"mappings":{"business":{"properties":{"address":{"type":"string"},"contactNumber":{"type":"string","store":true},"name":{"type":"string"}}}}}}
term
filter不分析输入文本,这意味着如果搜索“+1-415-392-3702”,那么这就是它希望在索引中找到的确切文本
但是,您的字段只是默认的字符串
,这意味着它很可能使用标准
分析器对其进行分析。这意味着在索引中您将有以下标记:“1”、“3702”、“392”、“415”
,而不是单个的+1-415-392-3702
因此,您需要这两个选项中的任意一个:
"contactNumber": {
"type": "string",
"index": "not_analyzed",
"store":true
}
或
contactNumber
的映射是什么?@andrestefan编辑以添加联系人编号的映射contactNumber
应该有一个不会改变其内容的分析器,例如关键字
,或者应该是未分析的
。您好,安德烈,您对elasticsearch的前端有什么建议吗。我希望经常创建/更新映射和索引,每次通过REST客户机创建/更新映射和索引都非常耗时。对于测试,可以使用Marvel的Sense dashboard,也可以使用其中一个客户端(Java、Python等),但后者需要编写一些代码。
"contactNumber": {
"type": "string",
"analyzer": "keyword",
"store":true
}