Configure ElasticSearch to use ngram by default. - SQL LIKE %% behavior

为君一笑 提交于 2019-12-11 16:49:26

问题


Is it possible to configure the elasticsearch index behavior to ack as the LIKE keyword of SQL.

If the index contains "This document is called MySuperInvoice", I want to be able to find it if I am looking for super, doc or voice"

Thank you for your help.

Edit:

Somebody tells me that I need to put * around my search terms : *query*

Lets see how this can be done using haystack.


回答1:


Ok I finally got there. Thanks @zebuline.

cluster:
        name: webapp
network:
        bind_host: 0.0.0.0
        publish_host: _eth0_
index:
        analysis:
                analyzer:
                        default_index:
                                type:           custom
                                tokenizer:      standard
                                filter:         [standard, lowercase, asciifolding, webapp_ngram]
                        default_search:
                                type:           custom
                                tokenizer:      standard
                                filter:         [standard, lowercase, asciifolding]
                filter:
                        webapp_ngram:
                                type:           nGram
                                min_gram:       1
                                max_gram:       30



回答2:


Have a look at default mapping in ES. It should help you.

http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html



来源:https://stackoverflow.com/questions/14160295/configure-elasticsearch-to-use-ngram-by-default-sql-like-behavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!