# DocValues on Strings Analyzed

**URL:** <https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901>\
**Category:** Elasticsearch\
**Created:** [April 11, 2017, 3:09am UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901 "2017-04-11T03:09:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![billnbell](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@billnbell](https://discuss.elastic.co/u/billnbell)\
**Post date:** [April 11, 2017, 3:09am UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/1 "2017-04-11T03:09:52Z")

</div>

Is there work being done on adding Strings analyzed to doc\_values fields? DocValues helps a lot with speed of Aggs and Sorting.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html)

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [April 14, 2017, 3:31pm UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/2 "2017-04-14T15:31:48Z")

</div>

You may be aware of this, but the `string` datatype is no longer really around as of 5.0: it's been replaced with `text` and `keyword` types. You can find more information about that [here](https://www.elastic.co/blog/strings-are-dead-long-live-strings). `keyword` types [already default to `doc_values` set to `true`](https://www.elastic.co/guide/en/elasticsearch/reference/master/keyword.html), so there are 2 implicit plausible questions:

- Does it ever make sense to have stemmed, multi-token strings like those values in `text` fields go into `doc_values`?
- Does it ever make sense to apply some analysis to single-token strings like those values in `keyword` fields and keep them in `doc_values`?

The answer to the first question is "_probably_ not." In your example, most of the time when you're sorting, you want to sort by the original raw text (e.g. that in a `keyword` field) rather than on the individual stemmed sub-tokens and the same is generally true of typical aggs usage as well.  
However, the answer to the second is "yes!" And in 5.2, we released [normalizers](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/analysis-normalizers.html) for this purpose. That is, you can do some lightweight analysis such as lowercasing or removing accents. There are other questions as to whether we should add other normalizer capabilities (e.g. query-time synonyms), which still haven't been answered.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Caputo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giovanni_caputo/32/10580_2.png) [@Giovanni\_Caputo](https://discuss.elastic.co/u/Giovanni_Caputo)\
**Post date:** [April 18, 2017, 10:01am UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/3 "2017-04-18T10:01:59Z")

</div>

The lowercase for a normalizers lose the case for orginal value.... How to?

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [April 21, 2017, 4:36pm UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/4 "2017-04-21T16:36:39Z")

</div>

Normalizers keep the original value/casing in `_source`

---

<div class="post-metadata">

**Author:** ![Giovanni\_Caputo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giovanni_caputo/32/10580_2.png) [@Giovanni\_Caputo](https://discuss.elastic.co/u/Giovanni_Caputo)\
**Post date:** [April 24, 2017, 7:19am UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/5 "2017-04-24T07:19:40Z")

</div>

> [@shanec](#):
>
> Normalizers keep the original value/casing in \_source

But cannot be used to aggregate.... i can not aggregate by value/casing and order by the aggregation case insensitive.

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [April 24, 2017, 3:58pm UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/6 "2017-04-24T15:58:36Z")

</div>

Can you describe what you're trying to do? You want to have all cases of values returned in an aggregation but have the results of the aggregation sorted case insensitively?

---

<div class="post-metadata">

**Author:** ![Giovanni\_Caputo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giovanni_caputo/32/10580_2.png) [@Giovanni\_Caputo](https://discuss.elastic.co/u/Giovanni_Caputo)\
**Post date:** [April 25, 2017, 4:55am UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/7 "2017-04-25T04:55:07Z")

</div>

Yes... I think that I can not use keyword type..

---

<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:** [May 23, 2017, 4:58am UTC](https://discuss.elastic.co/t/docvalues-on-strings-analyzed/81901/8 "2017-05-23T04:58:44Z")

</div>

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