DataToKnowledge / wheretolive.it

Apache License 2.0
0 stars 0 forks source link

exception for search page #7

Closed fabiana001 closed 7 years ago

fabiana001 commented 7 years ago

Example query:

{"aggs":{"crimes_0":{"terms":{"field":"crimes","size":20}},"regionName_1":{"terms":{"field":"regionName","size":5}},"cityName_2":{"terms":{"field":"cityName","size":10}},"categories_lower_3":{"terms":{"field":"categories.lower","size":15}}},"query":{"multi_match":{"query":"aa","fields":["title","description","semanticNames"],"fuzziness":0.4}},"sort":[{"date":{"order":"desc"}}]}

Running the above query it returns an illegal_arguments_exception, with the following message : Fielddata is disabled on text fields by default. Set fielddata=true on [crimes] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.

fabiana001 commented 7 years ago

Solution: Run the following code to enable fielddata on flat attributes:

PUT _mapping/articles
{
  "properties": {
    "crimes": { 
      "type":     "text",
      "fielddata": true
    }
  }
}
fabiana001 commented 7 years ago

For categories.lower:

PUT _mapping/articles
{
  "properties": {
    "categories": {
      "type": "text",
      "fields": {
        "lower": {
          "type": "text",
          "fielddata": true,
          "analyzer": "not_analyzed_lower"
        }
      }
    }
  }
}