How to setup a tokenizer in elasticsearch

后端 未结 2 1067
醉酒成梦
醉酒成梦 2020-12-09 11:20

I have an embedded elasticsearch using the elasticsearch-jetty project, and I need to setup to use tokenizers better than the defaults. I want to use the keyword tokenizer.<

相关标签:
2条回答
  • 2020-12-09 11:39

    You can define mappings in the config files, but for most cases it is easier/more flexible to configure through the API. For example, this command will add a keyword/lowercase analyzer to the index test:

    $ curl -XPUT localhost:9200/testindex/ -d '
    {
      "settings":{
         "index":{
            "analysis":{
               "analyzer":{
                  "analyzer_keyword":{
                     "tokenizer":"keyword",
                     "filter":"lowercase"
                  }
               }
            }
         }
      },
      "mappings":{
         "test":{
            "properties":{
               "title":{
                  "analyzer":"analyzer_keyword",
                  "type":"string"
               }
            }
         }
      }
    }'
    
    0 讨论(0)
  • 2020-12-09 12:03

    To update an existing index, use

    $ curl -XPUT localhost:9200/testindex/_settings -d '
    {
    ..........
    }
    

    However you can't update non dynamic settings.

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