Himadri Pant
Himadri Pant

Reputation: 2291

Elasticsearch : singular and plural results

We have used minimal_english stemmer filter in our mapping. This is to ensure that only singular and plural are searchable and not similar words. eg. Test and Tests should be searchable on entering the term - Test - but Tester,Testers,Testing should not be. On trying to search using the below RESTful API, multi_field attribute types are searchable but nested attribute types are not:

curl -X GET "http://10.113.124.136:9400/libtester/_search?pretty=true" -d '{
  "query": {
    "query_string": {
      "query": " DescriptionDescription ",
      "fields": [
        "abc"
      ]
    }
  }
}'

Mappings are as shown below :

{
  "properties": {
    "abc": {
      "type": "multi_field",
      "fields": {
        "c_asset_id": {
          "type": "string",
          "index": "analyzed",
          "include_in_all": true,
          "analyzer": "basic_english"
        },
        "untouched": {
          "type": "string",
          "index": "analyzed",
          "include_in_all": false,
          "analyzer": "string_lowercase"
        }
      }
    },
    "xyz": {
      "type": "nested",
      "properties": {
        "c_viewpoint": {
          "type": "multi_field",
          "fields": {
            "c_viewpoint": {
              "type": "string",
              "index": "analyzed",
              "include_in_all": true,
              "analyzer": "basic_english"
            },
            "untouched": {
              "type": "string",
              "index": "analyzed",
              "include_in_all": false,
              "analyzer": "string_lowercase"
            }
          }
        }
      }
    },
    ...
  }
}

Is this to do with the mapping of nested types - xyz, that they are not searchable from the same API that multi_field types are?

Upvotes: 4

Views: 3341

Answers (1)

Zach
Zach

Reputation: 9731

You can search nested properties, it just requires slightly different syntax. You have to specify the path, and then explicitly use the path for each property you are searching.

This tutorial has a good overview of how nested documents work.

Upvotes: 1

Related Questions