Home > Software engineering >  ElasticSearch: how can I check the way multiple analyzers split a text into tokens?
ElasticSearch: how can I check the way multiple analyzers split a text into tokens?

Time:01-09

I'm quite new to ElasticSearch, so if I overlook something obvious/basic, please forgive me.

I'm using ElasticSearch and want to see how analyzers applied to an index split a text into tokens. And as far as the result of GET /my_index/_settings displays, multiple analyzers are applied to the index, like following:

{
   "my_index": {
      "settings": {
          "analysis": {
             "analyzer": {
                "my_ngram_search_analyzer": {},
                "my_ngram_index_analyzer": {},
                "my_kuromoji_search_analyzer": {},
                "my_kuromoji_index_analyzer": {},
             }
          }
      }
   }
}

So I tried to analyze a text with multiple analyzers using an array, but it does not work.

GET /my_index/_analyze
{
   "text":"本日は晴天なり",
   "analyzer":["my_ngram_search_analyzer","my_kuromoji_search_analyzer"]
}

How can I perform this? I'd appreciate it if you would share some information.

CodePudding user response:

Analyze API doesn't support analysing a text with multiple analyzers and it works with just one analyzer, In the index you can define many analyzers which can be applied to various fields in Elasticsearch index.

You can also not apply multiple index time or search time analysers to a single field in Elasticsearch.

Hope this helps.

  • Related