简体   繁体   English

Elasticsearch前缀完全匹配

[英]Elasticsearch Prefix Exact Match

i have text fields like above 我有上面的文本字段

elastic|b|c
elastic,search|b|c
elastic,search,prefix|b|c

I want to query on this string with prefix. 我想查询带有前缀的字符串。 And the query is 和查询是

aggs":{  
   "field":{  
      "filter":{  
         "match":{  
            "field":{  
               "type":"prefix",
               "query":"elastic|"
            }
         }
      },
      "aggs":{  
         "field":{  
            "terms":{  
               "field":"textField",
               "size":255
            }
         }
      }
   }
}
},
"

and this query return all texts below in the example. 并且此查询返回示例中下面的所有文本。 Do i need extra analyzer or token filter on texts? 我需要文本上的额外分析器或令牌过滤器吗? How can i exact match search with prefix on elastic ? 如何在Elastic上使用前缀精确匹配搜索?

you can achieve that by using wildcards in elasticsearch. 您可以通过在Elasticsearch中使用通配符来实现。

{
  "query": {
"wildcard": {
      "textField": {
        "value": "elastic*"
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM