Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does minimizing json document size increase performance on elastic search?

I am seriously considering using elastic search as my primary database. The only thing holding me back is understanding whether or not json document size slows down elastic search. For example, if I index json documents with 100 fields rather than the 3 fields I need to search (and then querying my sql db for the other data), would elastic search be any slower?

Is this concern any reason not to use elastic search as my primary data storage? I will keep a backup in a traditional database so I can rebuild the index but my plan is to primarily query elastic search. Does this sound like a good idea?

like image 952
user531065 Avatar asked Oct 18 '25 13:10

user531065


1 Answers

Indexing all the fields in your JSON doc won't slow down Elasticsearch, but it will make your indexes bigger. So if disk space or RAM are limited, then perhaps you do only want to index the 3 relevant fields.

You can still store the whole doc in Elasticsearch (and set the _source field to be compressed) but disable the indexing of the irrelevant fields by setting them to "index": "no".

However if capacity isn't a problem, then why not let Elasticsearch just do its thing? You'll probably find that there are other relevant fields that you hadn't considered, and quite often you'll end up using ES to do queries that your DB would normally handle because (a) it's so damn fast and (b) it comes with easy scaling built in.

like image 157
DrTech Avatar answered Oct 21 '25 11:10

DrTech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!