I have a Rails app with this model:
class Product < ApplicationRecord
searchkick callbacks: false,
filterable: %i[id]
def search_data
{
id: ..
states: .. # e.g. { 'AU': 'oos', 'SG': 'draft' }
}
end
end
I'm able to filter string fields but not object fields using Searchkick.
Product.search('*', where: { id: 1 }, load: false) // success
if I use
Product.search('*', where: { "states.AU": "active" }, load: false)
it says failed to create query: Cannot search on field [states.AU] since it is not indexed. but I'm not able to include states field in filterable since its not a string field.
Searchkick::ImportError: {"type"=>"mapper_parsing_exception", "reason"=>"failed to parse [states]", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:177"}} on item with id '588'
how am I able to filter an object field using Searchkick? thanks