# Unsearchable keyword mapping (version 2.x -\> 5.x migration)

**URL:** <https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138>\
**Category:** Elasticsearch\
**Created:** [May 25, 2017, 2:14pm UTC](https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138 "2017-05-25T14:14:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![markwalsh-liverpool](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markwalsh-liverpool/32/8927_2.png) [@markwalsh-liverpool](https://discuss.elastic.co/u/markwalsh-liverpool)\
**Post date:** [May 25, 2017, 2:14pm UTC](https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138/1 "2017-05-25T14:14:16Z")

</div>

Hello,

I'm storing data by language in multiple indexes, one English index and multiple foreign languages. I store the same document in multiple indexes and I run aggregations across them, but I only want to aggregate the values from the English index.

Within my version 2.x mapping for my English index I have the following definition for a countryCode

```
   "countryCode": {
      "type": "string",
      "index": "not_analyzed"
   }

```

For all foreign languages (French, German etc) I have the following mapping

```
   "countryCode": {
      "type": "string",
      "index": "no"
   },

```

When I run aggregations on all of the indexes only the countryCode stored within the English index is evaluated (this is behaviour I want). Considering countryCode is a keyword, how do map this on version 5.0?

I tried this mapping for the foreign language documents:

```
           "countryCode": {
              "type": "keyword",
              "index": false
           },

```

But I receive the following error in the results:

```
"caused_by": {
                  "type": "illegal_argument_exception",
                  "reason": "Cannot search on field [countryCode] since it is not indexed."
               }

```

So in summation: I want to store the countryCode on all foreign language indexes but I don't want this evaluated when I am running aggregations.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 25, 2017, 5:40pm UTC](https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138/2 "2017-05-25T17:40:43Z")

</div>

Do you know ahead of time which indices are the English one? Can you  
execute the query on just that index, or does the query need to be across  
all indices?

You can always apply a filter aggregation to your countryCode aggregation:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html)

You can always filter on the value of the countryCode, either excluding or  
including, or even filter on the \_index field (do not recall if it is  
indexed in 5.x).

---

<div class="post-metadata">

**Author:** ![markwalsh-liverpool](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markwalsh-liverpool/32/8927_2.png) [@markwalsh-liverpool](https://discuss.elastic.co/u/markwalsh-liverpool)\
**Post date:** [May 25, 2017, 9:46pm UTC](https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138/3 "2017-05-25T21:46:02Z")

</div>

Hello, I search across all indexes as I don't know ahead of time, is this achievable?

To me it seems like it's not possible to just store a field and not doing anything with it in ES v5.x.?

---

<div class="post-metadata">

**Author:** ![markwalsh-liverpool](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markwalsh-liverpool/32/8927_2.png) [@markwalsh-liverpool](https://discuss.elastic.co/u/markwalsh-liverpool)\
**Post date:** [May 25, 2017, 9:56pm UTC](https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138/4 "2017-05-25T21:56:54Z")

</div>

In terms of targeting a specific a specific index for aggregations, could this be what you're referring to?

[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index-field.html)

---

<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:** [June 22, 2017, 9:57pm UTC](https://discuss.elastic.co/t/unsearchable-keyword-mapping-version-2-x-5-x-migration/87138/5 "2017-06-22T21:57:04Z")

</div>

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