Elasticsearch vs MongoDB for full text search
Asked Answered
C

2

6

This is a full text search question. I was using Elasticsearch for my logging system. And now I heard that MongoDB also supports full text search and tested the performance. I made a text index and tested it. With 10,000 words, 10 million documents were created. And it looked up two words. (ex. "apple pineapple") The results were surprising. MongoDB searches were faster.

Am I misunderstanding full text search in Elasticsearch?? did i do the test wrong? In terms of full text search performance, is there no reason why Elasticsearch should be used? Am I misunderstanding full text search?? Please teach me.

Cornell answered 11/1, 2022 at 10:40 Comment(2)
Please add the exact query functions that you were using for Elasticsearch and MongoDB. Also provide details on how you measured the performance.Alfonsoalfonzo
did i do the test wrong? - how do we know if you didn't share your tests? Mongodb added support for full text search. It's not it's primary function and you can find many questions here on SO where people struggle with lack of some functionality they had in Elasticksearch - the purpose built fulltext search engine. It's one of the reasons why Mongo db provides seamless integration with Elasticsearch in their commercial offering on Atlas. If you need mongo functionality and its fulltext is sufficient for your usecases go for it.Generate
C
4

If your use case is full text search only, I will still be more inclined towards Elasticsearch as it is designed for the same. I admit however that I haven't explored Mongodb capabilities in this regard. Elasticsearch provides various search paths fuzzy, proximity matches, match phrases and more which can be used depending on your use case.

One another difference between Elastic and Mongo's data storage is that Elastic keeps everything in memory while Mongo balances between disk and memory. So ideally Elastic should be faster if you load test it.

In terms of your test, please make sure that both mongo and elastic clusters are of equivalent strength in terms of resources. Else it is not apple to apple comparison.

Chuff answered 11/1, 2022 at 11:31 Comment(0)
G
2

if your search use case is just matching simple text like exact terms or phrase matches with basic sorting MongoDB full-text search will work fine. MongoDB supports index time boosting of the fields.

If you need the support of fuzzy search (matching records even with typos in the search query), additional things like search time boosting, complex sorting things based on decay functions, sort builders, etc.. then I would say go with Elastic Search.

source - https://discuss.elastic.co/t/mongodb-full-text-search-vs-elasticsearch/212143/4

Geronto answered 3/4 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.