# Document fields do not always get \*.keyword entries

**URL:** <https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474>\
**Category:** Open Source Elasticsearch and Kibana\
**Tags:** troubleshoot\
**Created:** [October 27, 2023, 3:30pm UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474 "2023-10-27T15:30:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerakin](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jerakin](https://forum.opensearch.org/u/Jerakin)\
**Post date:** [October 27, 2023, 3:30pm UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/1 "2023-10-27T15:30:30Z")

</div>

Hi

I am logging my exceptions and adding my strack trace to as `error.stack_trace` when I display this I use `error.stack_trace.keyword`. I can see my old entries fine but I can not see any new stack\_traces. If I use the discover functionality I can see them all under `error.stack_trace` but not under `error.stack_trace.keyword`. Is there something that I need to do to make sure my string entries gets “keyworded” automatically?

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [October 30, 2023, 3:04am UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/2 "2023-10-30T03:04:55Z")

</div>

You can check the mappings of the index to see if the field `error.stack_trace.keyword` exists, you may add the field’s mapping to the index template(if not exist you can create one) to make sure that every new index contains that field.

---

<div class="post-metadata">

**Author:** ![Jerakin](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jerakin](https://forum.opensearch.org/u/Jerakin)\
**Post date:** [October 30, 2023, 2:27pm UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/3 "2023-10-30T14:27:16Z")

</div>

That does not seem to be it. It seems that some of the logs with `error.stack_trace` get properly handled and get the `error.stack_trace.keyword` entry but not all.

---

<div class="post-metadata">

**Author:** ![radu.gheorghe](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/radu.gheorghe/32/3516_2.png) [@radu.gheorghe](https://forum.opensearch.org/u/radu.gheorghe)\
**Post date:** [November 3, 2023, 6:33am UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/4 "2023-11-03T06:33:43Z")

</div>

You mean that in Discover you want to see the value of the `.keyword` subfield? I don’t think you can do that normally, because subfields aren’t stored in `_source`, you only get the parent field (in your case, `error.stack_trace` stored.

Though the API, you can get the contents of the `.keyword` subfield by default if you ask for it in `docvalue_fields`.

---

<div class="post-metadata">

**Author:** ![Jerakin](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jerakin](https://forum.opensearch.org/u/Jerakin)\
**Post date:** [November 3, 2023, 8:32am UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/5 "2023-11-03T08:32:44Z")

</div>

Not quite. I mean that when I filter in the Discover view on `error.stack_trace.message` not everything from `error.stack_trace` shows. Especially newer message doesn’t have the `.message`.

---

<div class="post-metadata">

**Author:** ![radu.gheorghe](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/radu.gheorghe/32/3516_2.png) [@radu.gheorghe](https://forum.opensearch.org/u/radu.gheorghe)\
**Post date:** [November 6, 2023, 12:33pm UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/6 "2023-11-06T12:33:15Z")

</div>

I don’t quite get how your mapping looks like. Can you share a relevant snippet?

---

<div class="post-metadata">

**Author:** ![Jerakin](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jerakin](https://forum.opensearch.org/u/Jerakin)\
**Post date:** [November 29, 2023, 3:23pm UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/7 "2023-11-29T15:23:20Z")

</div>

Hi again! Sorry for the incredibly late response, have been busy with other parts of this project.

I think the mapping looks like it should.

```json
            "stack_trace": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },

```

When I search in Discover for `error.stack_trace.keyword: exists` I get 2 hits vs 74 hits for `error.stack_trace: exists`

---

<div class="post-metadata">

**Author:** ![radu.gheorghe](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/radu.gheorghe/32/3516_2.png) [@radu.gheorghe](https://forum.opensearch.org/u/radu.gheorghe)\
**Post date:** [December 8, 2023, 7:41am UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/8 "2023-12-08T07:41:45Z")

</div>

No worries about the delay, it’s all best-effort here 🙂

I think it’s because of `ignore_above`. If your string is more than 256 characters (and most stacktraces are), it gets ignored (i.e. not indexed). At least that’s my understanding. So when you search the keyword you don’t get anything.

But wait, `exists` is a keyword that you’re searching in the stacktrace? In that case you want to search in the text field, because that is tokenized. The keyword field is indexed as one big token.

If you want to search for docs that have any value in a field, you’d search for `field:*`, but I still think you wouldn’t get documents where the value is ignored, I don’t now for sure.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [February 6, 2024, 7:42am UTC](https://forum.opensearch.org/t/document-fields-do-not-always-get-keyword-entries/16474/9 "2024-02-06T07:42:41Z")

</div>

Closed on February 6, 2024, 7:42am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
