0

ES 7.8, mapping:

    "id": {
      "type": "text",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 300
        },
        "lower_case_sort": {
          "type": "keyword",
          "ignore_above": 10,
          "normalizer": "case_insensitive_sort"
        }
      }
    }

How can I search my index and get id.keyword and id.lower_case_sort values? All I can get is id value

1 Answer 1

2

You can retrieve the actual terms that have been indexed in sub-fields using docvalue_fields (only works for non-text fields).

For instance, if you index this

POST test/_doc
{
  "id": "ONE two"
}

You can retrieve the actual doc values using:

GET test/_search
{
  "docvalue_fields": ["id.keyword", "id.lower_case_sort"]
}

And you'll get this:

"hits" : [
  {
    "_index" : "test",
    "_type" : "_doc",
    "_id" : "bZ3NenMBfUaK6xUNT7vB",
    "_score" : 1.0,
    "_source" : {
      "id" : "ONE two"
    },
    "fields" : {
      "id.lower_case_sort" : [
        "one two"
      ],
      "id.keyword" : [
        "ONE two"
      ]
    }
  }
]

As you can see, you get

  • the original value in _source.id
  • the indexed doc values for each sub-field in fields.id.keyword and fields.id.lower_case_sort
Sign up to request clarification or add additional context in comments.

2 Comments

only works for non-text fields ? ah ok, keyword is not text
What I meant was only on fields that are not of type text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.