ElasticSearch - Searching with hyphens

前端 未结 3 1414
离开以前
离开以前 2020-12-16 02:17

Elastic Search 1.6

I want to index text that contains hyphens, for example U-12, U-17, WU-12, t-shirt... and to be able to use a \"Simple Query String\" query to sea

3条回答
  •  再見小時候
    2020-12-16 03:11

    If anyone is still looking for a simple workaround to this issue, replace hyphen with underscore _ when indexing data.

    For eg, O-000022334 should indexed as O_000022334.

    When searching, replace underscore back to hyphen again when displaying results. This way you can search for "O-000022334" and it will find a correct match.

提交回复
热议问题