[英]Is there a way to get exact location of query match in elastic search documents
[英]how to get exact search result from elastic search query
我需要来自弹性搜索查询的精确匹配结果
我尝试在使用此 curl 命令建立索引时将索引保持为“未分析”:
curl -X PUT es/_doc/all -H'Content-Type: application/json' -d '{
"mappings": {
"dynamic_templates": [
{
"example_string_as_object": {
"match_mapping_type": "object",
"match": "x-example",
"mapping": {
"type": "string",
"index": "not_analyzed"
}
}
}
]
}
}'
但是,当我尝试使用“account-validity”进行查询时,我得到了“account”和“validity”的结果。
我需要显示仅具有“帐户有效性”的文档的结果。 我正在使用的查询:
es/_search?size=1000&from=0&q=account-validity&pretty=true
有人可以帮我解决这个问题吗
我能够通过在需要精确搜索的数据之前使用参数“term”来解决这个问题。
PFB 一个示例,它显示了 name = ABC 的完全匹配
{
"query" : {
"constant_score" : {
"filter" : {
"term" : {
"Name" : "ABC"
}
}
}
}
}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.