英文:
Can I use Elasticsearch for query DB in replace of standard DB?
问题
MongoDB,例如,很不错,但它没有全文搜索(Atlas Search 有,但它是不同的东西)。此外,您需要显式地对字段进行索引。
Elastic 允许对文档中的每个字段进行动态索引。所以基本上每个字段都被索引了,您可以非常快速地查询所有的数据(顺便问一下,这样做好吗?只需添加大量文档并让它们都被索引?)
所以我想当我只需要查询数据,没有任何变更或 ACID 事务时 - 例如 - 给我列出在 StackOverflow 公司工作的员工名单,然后添加一个筛选条件,筛选出在开发者角色中工作超过 5 年的人,然后添加一个名字以 "Dan" 开头的全文搜索。所有这些都可以通过 Elastic 实现。
所以它可能是 MongoDB/MySQL/Postgres 等的完全替代品 - 仅用于查询。不是吗?
英文:
MongoDB, for example, is great but it has no full-text search (Atlas Search does, but its a different thing). Also you need to explicitly index fields.
Elastic allows dynamic indexing per every field in the document. So basically every field is indexed and you can query against all of your data very fast (btw is it good to do so? just drop tons of documents and let them all be indexed?)
So I guess that when I need just to query data, without any mutations or ACID transactions - for example - give me the list of employees who work for a company StackOverflow, then add filter of who works for more than 5 years in role of developer, then add full-text search for name starts with "Dan". All of these can be achieved by Elastic.
So probably it can be a full replacer for MongoDB/MySQL/Postgres/etc - for query only. Isn't it?
答案1
得分: 2
Certainly, here is the translation:
- Elasticsearch支持连接,父子查询,但与MySQL相比性能较差。
- Elasticsearch查询数据速度较慢,因为有提升查询(boost query)。
- 注意聚合查询(aggr),如计数和去重,存在精度问题。因为Elasticsearch是基于分片设计的,来自多个分片的聚合会较慢且不够准确。
- 精通Elasticsearch查询计数,因为Elasticsearch DSL比传统SQL更复杂。
- Elasticsearch使用比其他数据库更多的磁盘空间,因为需要对文本字段进行分析。
查询性能对于各种类型的数据库都很重要。
英文:
Yes, but still there are something you need take into consideration.
- elasticsearch supports join , parent-child query with very poor performance comparing to mysql.
- elasticsearch query data slower than other db, cause of boost query.
- Pay attention to aggr, such as count, distinct, there is a precision problem. As elasticsearch is designed with shards, aggregation from mutilple shards will be slow and inaccuracy.
- Proficiency of elasticsearch query counts, as elasticsearch DSL is more complex than traditional SQL.
- elasticsearch use more disk than other db, cause of analyzation of text field.
Query performance counts for every kinds of db.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论