2

We have a Rails 4 app running on two similar environments, staging and production.

Lately, this error started appearing on local development environments and the staging environment, but is not happening on production.

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {
  "error": {
    "root_cause":[{ "type": "illegal_argument_exception",
      "reason":"Fielddata is disabled on text fields by default. 
        Set fielddata=true on [updated_at] 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 instead."}],
      "type":"search_phase_execution_exception",
      "reason":"all shards failed",
      "phase":"query",
      "grouped":true,
      "failed_shards":[{"shard":0,
      "index":"users",
      "node":"xxxxxxxxxxxxxxxxxxxxxxxx",
      "reason":{"type":"illegal_argument_exception",
        "reason":"Fielddata is disabled on text fields by default. 
          Set fielddata=true on [updated_at] 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 instead."}
    }]
  },
  "status":400
}

I know that the ElasticSearch documentation explains how to solve this error. However, I would like to know what could be triggering the error on those environments, given that the ES configuration and queries used are identical in staging and production.

Ramses
  • 996
  • 4
  • 12
  • 28
  • 2
    Can you provide the mapping for both staging and production? It looks like `updated_at` may be mapped differently, either as a different type (the name _looks_ like it would be mapped as `date`, but the error indicates it's mapped as `text`) or _without_ `fielddata` set to `true`. How are the mapping created in both environments? – Russ Cam Aug 08 '18 at 04:15
  • Managed to check the mapping directly on ES on both environments. The mapping on production was altered directly and not through the Chewy index file, and the updated_at field was set as `keyword` on prod. Thanks for your comment, @RussCam! – Ramses Aug 08 '18 at 18:33
  • Can you please share how you solved this problem? – UsamaMan Jul 25 '22 at 17:31
  • @UsamaMan our production environment had `updated_at` mapped as `text` -- So I changed it to `keyword` – Ramses Jul 26 '22 at 15:52
  • @Ramses After that I would need to reindex the model? – UsamaMan Jul 26 '22 at 19:49
  • @UsamaMan yes, that's correct – Ramses Jul 27 '22 at 15:50

0 Answers0