简体   繁体   中英

Elasticsearch match hyphen

I need to match word like "1-2", however I am using standard analyzer which ignores "-",

  • I cannot use "analyze_wildcard": true because it will return tokens like "1", "-", "2", which is not ideal solution.

  • I cannot use third party plugin.

I am trying to set customized tokenizer by using regular expression, however none of them works.

I think the best way is to switch off the analyzer of your field, in which you want to match "1-2". Don't forget to use no analyzer on your search query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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