Pushing code to a clean instance without any items in the index results in stacks. Any way of handling this more gracefully?
No mapping found for [updated_at] in order to sort on
query = Product.search "*", page: params[:page], per_page: 15,
order: {updated_at: :desc},
fields: [:name, :description],
execute: false
@products = query.execute
Unfortunately, I'm not aware of one. You can specify your own mapping to include updated_at (not ideal), but until a product is indexed that has an updated_at field, Elasticsearch won't have a mapping for it - and Searchkick won't know what your search_data method returns without at least one record.
Found this, There is an option to ignore unmapped fields when sorting:
Allow search to continue when sort field is missing from type mapping
https://github.com/elasticsearch/elasticsearch/issues/1558
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html
Cool, looks like ES has solved the issue. Just need to make the order option more flexible to support as much as possible of http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html
Looks like it's already supported.
Product.search "*", order: {updated_at: {order: "desc", ignore_unmapped: true}}
:+1:
Most helpful comment
Looks like it's already supported.