以下查询和索引不会返回预期结果。考虑到映射约束,我不明白,当我搜索" ICD9"它还返回" I9"的结果。和" 9"等等。有什么想法吗?
Here is the index mapping:
{
"mappings": {
"mymap": {
"dynamic_templates": [
{
"codingstandard": {
"match": "*.CodingStandard",
"mapping": {
"type": "string",
"index": "not_analyzed"
}
}
}
]
}
}
}
Here is my query:
{
"fields": [
"Diagnosis.CodingStandard"
],
"query": {
"query_string": {
"query": "Diagnosis.CodingStandard:ICD9"
}
}
}
Here are some of my results:
"hits": {
"total": 9778,
"max_score": 3.501487,
"hits": [
{
"_index": "myindex",
"_type": "mymapping",
"_id": "264235",
"_score": 3.501487,
"fields": {
"Diagnosis.CodingStandard": [
"I9"
]
}
},
{
"_index": "myindex",
"_type": "mymapping",
"_id": "264261",
"_score": 3.501487,
"fields": {
"Diagnosis.CodingStandard": [
"9"
]
}
},
etc...
答案 0 :(得分:0)
是的,因为你正在使用query_string,elasticsearch默认为query_string做模糊搜索。
如果您想进行精确搜索,可以使用filter而不是query_string
{
"query":{
"filtered":{
"filter":{
"term":{
"Diagnosis.CodingStandard": "ICD9"
}
}
}
}
}