Mike Riley Mike Riley - 28 days ago 6
Ruby Question

Elasticsearch Rails as_indexed_json vs mappings

I am using the Elasticsearch Rails gem and I am using two things in my model:

def as_indexed_json

end


and

settings index: { number_of_shards: 1 } do
mapping dynamic: 'false' do

end
end


I have read the documentation and I am not understanding what the purposes of each of these are. What I am trying to figure out is are these used for searching the indexed data or for creating the indexed data?

gfd gfd
Answer

The as_indexed_json method is used to override what data will be send to ES for indexing. How ES is indexing the data you send is configured by the second part.

To search with ES in the indexed data, you have to perform a _query.

Feel free to ask if you need more info