使用 Elasticsearch 与标准 sql 查询相比有哪些用例?

What are some use cases for using Elasticsearch versus standard sql queries?

我刚刚开始使用 Elasticsearch,我看到的主要用例之一是它在大型数据集上的搜索的可扩展性,但除此之外,你什么时候想使用它而不是仅仅创建 sql 使用传统 RDBMS 查询?

有两个主要的 Elasticsearch 用例:

  1. 文本搜索

当您进行大量文本搜索时,您需要使用 Elasticsearch,而传统 RDBMS 数据库的性能并不是很好(配置不佳、充当黑盒、性能不佳)。 Elasticsearch 是高度可定制的,可通过插件扩展。您无需太多知识即可快速构建强大的搜索。

  1. 记录和分析

另一个边缘案例是很多人使用 Elasticsearch 来存储来自不同来源的日志(以集中它们),这样他们就可以分析它们并从中获得意义。在这种情况下,Kibana 就派上用场了。它可以让您连接到 Elasticsearch 集群并立即创建可视化。例如,Loggly 是使用 Elasticsearch 和 Kibana 构建的。

请记住,您不会希望使用 Elasticsearch 作为您的主要数据存储。这里的原因:How reliable is ElasticSearch as a primary datastore against factors like write loss, data availability

更新

我觉得第二部分不再前卫,这实际上是 Elastic 作为一家公司在过去一年中做得非常好的地方。随着当前的 DevOps 运动、CI/CD 管道、来自各种来源的越来越多的指标,ELK 成为基础设施监控的事实上的选择,它不再只是一个分布式 RESTful 文本搜索引擎。它有一套很棒的产品:

  • Logstash(大量数据输入)
  • 节拍
    • Filebeat
    • Metricbeat
    • Packetbeat
    • Winlogbeat
  • 基巴纳
    • 图表
    • 时狮
  • X-Pack(高级版)
    • 警报
    • 举报
    • 安全
    • 机器学习
    • 跨数据中心指标

一个由社区构建的生态系统正在围绕扩展当前功能的 ELK 堆栈发展,其中一些值得一提:

  • ElastAlert
  • 搜索卫士

补充另一个答案,日志记录和搜索仍然是一个主要用例,但现在指标和分析变得越来越重要。

我相信 post 总结了推动大数据新用例的市场变化。 All you really need to know about Open Source Databases

With the advent of Web 2.0, static web pages have become dynamic and social media is all around us. Everyone is tweeting, posting, blogging, vlogging, sharing photos, chatting and commenting. The Internet of Things (IoT) is emerging — a rapidly growing network of connected devices that collect and exchange data, such as sensors and smart devices. There are some great examples here.

Altogether, this generates huge amounts of new data that businesses want to absorb and use to stay ahead, to provide features such as product recommendations and a better customer experience. The data can be analyzed in search of patterns for applications such as fraud detection and behavior analytics. Much of the new data is unstructured, which means that it can’t be neatly stored in a tabular database.

Imagine trying to design a database to hold data on your grocery shopping — what you like, how often you buy it, whether you prefer milk or cream with your coffee. New types of databases are needed to store the new data, and they need to be non-relational and ideally low cost. Ring any bells? Not relational as in NoSQL and low cost as in open source.

我采访过的一位 Elasticsearch 架构师说,Elasticsearch 在公司中使用的数据中有 80% 是非结构化的,而 20% 是结构化的。 公司正在查看非结构化数据以发现罕见或不寻常的数据模式。他们还使用 Elasticsearch 来监控数据模式。例如,一家大型零售商正在使用 Elasticsearch 进行实时跟踪,以确保商店有足够的货币供应,供人们在发薪日兑现支票。

根据我自己的搜索用例经验,我们不仅使用模糊搜索,而且还演变成自动完成和快速搜索。据我所知,一旦您开始使用 Elasticsearch,您就会开始发展到其他用例来补充您已有的用例。既然我们已经将 Elasticsearch 作为我们公司的模糊搜索引擎,我们现在有其他团队正在研究日志记录的分析和指标。

以下是一些更深入探讨此主题的其他资源: