ElasticSearch - Searching with hyphens in name

后端 未结 1 1318
没有蜡笔的小新
没有蜡笔的小新 2020-12-19 10:23

I have a product catalog which I am indexing in ElasticSearch using the Elastica client. I am very new to ElasticSearch BTW.

There are products in my catalog which h

相关标签:
1条回答
  • 2020-12-19 10:58

    You can try removing the hyphen using a mapping char filter:

    http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-mapping-charfilter.html

    something like this would remove the hyphen:

    {
        "index" : {
            "analysis" : {
                "char_filter" : {
                    "my_mapping" : {
                        "type" : "mapping",
                        "mappings" : ["-=>"]
                    }
                },
                "analyzer" : {
                    "custom_with_char_filter" : {
                        "tokenizer" : "standard",
                        "char_filter" : ["my_mapping"]
                    }
                }
            }
        }
    }
    

    it's something of a blunt force instrument as it will strip all hyphens but it should make "t-shirt" and "tshirt" match

    0 讨论(0)
提交回复
热议问题