Aviran
Aviran

Reputation: 5458

Index field is mapped as text instead of keyword

Experiencing an issue with ES, I have a mapping for a user type, specifying a field as keyword

GET _template/user_template

Returns:

{
 ...
 "primary_user": {
            "type": "keyword"
          }
}

The following filter request will return with hits

GET users/user/_search
{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "primary_user.keyword": "AWBFyulcxxxxxxxx"
        }
      }
    }
  }
}

The following request will return with 0 hits.

GET users/user/_search
    {
      "query": {
        "bool": {
          "filter": {
            "term": {
              "primary_user": "AWBFyulcxxxxxxxx"
            }
          }
        }
      }
    }

From the Dev tools autocomplete, I can see the ES regards the primary_user as text.

enter image description here

What am I missing?

Upvotes: 0

Views: 232

Answers (1)

Dario Balinzo
Dario Balinzo

Reputation: 691

Check the name of the index with the template index pattern: the template will be applied only to index with name matching the index pattern.

In addition templates are only applied at index creation time and changing a template will have no impact on existing indices: if you have updated the template, you have to create a new index (ord deleting and recreating an existing one) for viewing the changes in the mapping.

Upvotes: 1

Related Questions