0

I am doing a sort on an Elasticsearch field but it gives me an error.

I do this:

s = s.sort({'productForm': {"order": "desc"}})

I get the following error

RequestError(400, u'search_phase_execution_exception', u'Fielddata is disabled on text fields by default. Set fielddata=true on [productForm] 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.')

I understand that fields need to be of the type keyword, so my mapping is like this

},
"productForm": {
"analyzer": "keyword",
"type": "text"
},

What am I missing to make this work

Thanks

Grant

mozman2
  • 911
  • 1
  • 8
  • 17

1 Answers1

0

I managed to fix this, but not sure why I need to do what I do.

I needed to change the mapping, so it looked like this

"productForm": {
"analyzer": "keyword",
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}

Then I could do this

"sort":["productForm.keyword"]

Thanks

Grant

mozman2
  • 911
  • 1
  • 8
  • 17