honey
honey

Reputation: 23

How to use nested mapping in language analyzer

I am presently working with language analyzer in elasticsearch. In this I found that if we need to use the analyzer for searching documents then we need to define mapping along with analyzer. In my case, if document contains a normal text field this works fine but when I apply same property to a nested field then the analyzer is not working.

This is code for language analyzer

PUT checkmap
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stemmerenglish": {
          "tokenizer": "standard",
          "filter": [
            "standard",
            "lowercase",
            "my_stemmer"
          ]
        }
      },
      "filter": {
        "my_stemmer": {
          "type": "stemmer",
          "name": "english"
        }
      }
    }
  },
  "mappings": {
    "dd": {
      "properties": {
        "Courses": {
          "type": "nested",
          "properties": {
            "Sname": {
              "type": "text",
              "analyzer": "stemmerenglish",
              "search_analyzer": "stemmerenglish"
            }
          }
        }
      }
    }
  }
}

Please help me out with above problem.

Upvotes: 0

Views: 149

Answers (1)

Richa
Richa

Reputation: 7649

You have to use Nested Query for nested type. Use following Query

GET checkmap/_search
{
 "query": {
  "nested": {
     "path": "Courses",
     "query": {
        "match": {
           "Courses.Sname": {
              "query": "Jump"
             }
          }
        }
      }
    }
  }

Read more here

Upvotes: 2

Related Questions