How does Searchkick/ElasticSearch impact how I should structure my database indexes?
I have a couple of questions about implementing Searchkick and ElasticSearch in general.
Let's say I'm using ElasticSearch to search for products like so:
# usage Product.search "apples", fields: [:name] - # model class Product < ApplicationRecord searchkick, searchable: [:name], filterable: [] def search_data { name: name } end end
I don't search by name in any other case (no ActiveRecord queries). Should I remove the table index I have on the name column? (as seen below)
# remove this? add_index :products, :name
Follow up question: If I'm feeding data to the ElasticSearch server from my database, will indexing (in my db) the search_data fields impact how efficient the
Product.reindex
function will be? For example:# if I have this in my Product model: # (It tells ElasticSearch to only reindex the name attribute) def search_data { name: name } end - # Does the index by name below impact the reindexing process's speed? # If so, is it worth it? add_index :products, :name
Lastly, could Searchkick be the mechanism I use to query most of my data? When is it not recommended to use ElasticSearch? What are some drawbacks, other than losing ActiveRecord functionallity? It seems like it wouldn't be too complicated to add
searchkick
to mostly all your models and query everything like that.
Thanks in advance for the help! <3
Matias,
Did you ever get an answer to this? I've been wondering about the same things recently.