Home > Software design >  How does Elasticsearch query by text so fast?
How does Elasticsearch query by text so fast?

Time:06-15

I have been learning about Elasticsearch for some time now.

I want to see if the following statement es correct:

Elasticsearch manages such high speeds because you can split data that is in the same index between several nodes that will take a GET query and run it at the same time.

Meaning if I have three pieces of data in the "book" index

{"name": "Pinocchio"}
{"name": "Frozen"}
{"name": "Diary of A Wimpy Kid"}

And I decide to give the cluster three nodes, each node will hold one of the three books and therefore speed up my get request 3x?

CodePudding user response:

Yes, there's much more to it, but that's pretty much what happens behind the scene.

Provided your index has three primary shards and each shard lands on a different node and contains one of the documents in your question, when you execute a query on your index, the query gets broadcast to each of the shards of your index and is executed on each node in parallel to search the documents on that node.

CodePudding user response:

You have mentioned the one of the advantages of Elasticsearch as it distributes data (Shards and Replica) on multiple server and query will be executed parallel. it is useful for High Availibility as well.

Another reason is due to how elasticsearch internally store data. It use Lucene which stored data in inverted Index.

You can check below link for more explanation:

Why Elasticsearch is fatser comapre to raw SQL command

How Elasticsearch Search So Fast?

How is Elasticsearch so fast?

  • Related