Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
    indexes :id
    indexes :customer do                                                                                                                                                                                                                          
      indexes :first_name
    end
  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?

like image 634
Mike Riley Avatar asked Nov 11 '16 14:11

Mike Riley


1 Answers

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

like image 54
gfd Avatar answered Nov 07 '22 10:11

gfd