elasticsearchanalyzersenseelasticsearch-mapping

How to analyze a sentence when analyzer is given inside a property of mapping - elasticsearch


here is a simple question:

Normally when i give the analyzer outside of the mapping i query the sentence like:

POST three_in_one_index4/_analyze
{
    "analyzer": "english_lower",
    "text": "<p>lorem ipsum dolor sit amet.</p>"    
}

Now i give the analyzer inside of the mapping like:

"mappings": {
    "column": {
      "properties": {
        "article1": {
          "type": "text",
          "analyzer": "english_lower"
        },
        "article2": {
            "type": "text",
            "analyzer": "latin_lower"
        },
        "article3": {
            "type": "text",
            "analyzer": "latinstem_and_englishlower"
        }
      }
    }
  }

So now how should the analyzing be like?

I'm pretty sure that below is not working as what i mean to do.

POST three_in_one_index4/_analyze
{
    "analyzer": "english_lower",
    "text": "<p>lorem ipsum dolor sit amet.</p>"    
} 

Solution

  • If you want to analyze the tokens based on the analyzer for a field as defined in your mapping, then you can do it like :

    curl -XGET 'localhost:9200/three_in_one_index4/_analyze' -d '
    {
      "field" : "article1",
      "text" : "<p>lorem ipsum dolor sit amet.</p>"
    }'
    

    Will cause the analysis to happen based on the analyzer configured in the mapping for article1 (and if not, the default index analyzer).