# Possible to use truncate filter on keyword subfield to limit length?

**URL:** https://discuss.elastic.co/t/possible-to-use-truncate-filter-on-keyword-subfield-to-limit-length/150231
**Category:** Elasticsearch
**Created:** [September 27, 2018, 5:32pm UTC](https://discuss.elastic.co/t/possible-to-use-truncate-filter-on-keyword-subfield-to-limit-length/150231 "2018-09-27T17:32:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jaddison](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jaddison](https://discuss.elastic.co/u/jaddison)
#### Post date: [September 27, 2018, 5:32pm UTC](https://discuss.elastic.co/t/possible-to-use-truncate-filter-on-keyword-subfield-to-limit-length/150231/1 "2018-09-27T17:32:00Z")

</div>

I'm looking to overcome **`Fielddata is disabled on text fields by default. ... Alternatively use a keyword field...`**

I have a `text` field - it can be very large. I want to be able to test for field existence/length in `script_score` querying, so I'm thinking to add a `keyword` subfield on the `text` field and use a `truncate` filter to reduce the keyword data to a minimum amount. Is this possible?

If I could truncate the `keyword` subfield to a single character, that would be fine.

[Related to this other question](https://discuss.elastic.co/t/discover-fielddata-is-disabled-on-text-fields-by-default-set-fielddata-true-on-user-in-order-to-load-fielddata-in-memory-by-uninverting-the-inverted-index-note-that-this-can-however-use-significant-memory-alternatively-use-a-keyword-field/93214).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 25, 2018, 5:32pm UTC](https://discuss.elastic.co/t/possible-to-use-truncate-filter-on-keyword-subfield-to-limit-length/150231/2 "2018-10-25T17:32:00Z")

</div>

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