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

(Markwalsh Liverpool) #1


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.

(Ivan Brusic) #2

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:

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).

(Markwalsh Liverpool) #3

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.?

(Markwalsh Liverpool) #4

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


(system) #5

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