Elasticsearch基础篇(一):Elasticsearch简介

前言

本篇将介绍Elasticsearch是什么,了解Elasticsearch是如何成为分布式搜索和分析引擎的核心,以及它如何处理索引、搜索和分析数据。同时还分享一些学习Elasticsearch的方法和资源, 能够快速的学习和上手完成工作需要。同时为了提升自己对于英文文档的学习的阅读能力,本文会大量引用官方文档的英文原文。

本文基于官方文档:Elasticsearch Guide [7.9]

1. Elasticsearch简介

Elasticsearch是一个开源的分布式搜索和分析引擎,它构建在Apache Lucene搜索库之上。它被设计用处理大规模数据集并提供实时搜索和分析功能。Elasticsearch具有高可用性、可扩展性和容错性,能够快速地处理结构化和非结构化数据。

它支持全文搜索、实时数据分析和复杂的查询,可用于构建各种应用程序,包括日志分析、实时指标和指标可视化、全文搜索、安全分析等。Elasticsearch提供Restful API,开发人员可以轻松地与其进行交互,并支持各种编程语言的客户端。

Elasticsearch以分布式的方式运行,可以将数据分片并分布到多个节点上,以实现水平扩展和负载均衡。它还提供了强大的查询和聚合功能,允许用户对数据进行复杂的分析和挖掘

2. Elasticsearch的特点和用途

Elasticsearch具有以下特点和用途,根据官方文档和实际使用情况,可以举例说明其在许多公司和机构中的应用。

2.1 es的主要特点

  1. 分布式和可扩展性:Elasticsearch使用分布式架构,可以轻松地水平扩展,处理大规模数据集并提供高性能的搜索和分析功能。
  2. 实时性能:Elasticsearch提供了近实时(near real-time)和分析能力,能够快速地响应查询请求,支持快速迭代和交互式探索数据。
  3. 多种数据类型支持:Elasticsearch支持多种数据类型,包括结构化、半结构化和非结构化数据,可以应对各种应用场景的数据存储需求。
  4. 强大的查询和聚合功能:Elasticsearch提供了丰富的查询语言和聚合功能,使用户能够执行复杂的查询和数据分析操作,包括全文搜索、过滤、排序、分组等。
  5. 文档导向:Elasticsearch以文档为单位进行数据存储和检索,每个文档都有一个唯一的ID,便于管理和组织数据。

2.2 es搜索和数据分析的用途

  1. 搜索引擎:Elasticsearch最常见的用途之一是构建实时搜索引擎。许多公司和网站使用Elasticsearch来提供快速、准确的搜索功能,例如在线商店的产品搜索、新闻网站的文章搜索等。
  2. 日志分析:由于其高性能和实时性能,Elasticsearch被广泛用于处理大量日志数据。许多公司使用Elasticsearch来集中存储和分析日志数据,进行故障排除、安全分析和性能监控等。
  3. 数据分析和可视化:Elasticsearch与Kibana等工具的结合可以用于实时数据分析和可视化。例如,公司可以使用Elasticsearch来存储和分析销售数据,并使用Kibana创建仪表板和图表来监控销售趋势和业务指标。
  4. 实时监控和警报:许多公司使用Elasticsearch来实时监控系统指标、网络流量、应用程序日志等。当特定条件满足时,可以设置警报机制,及时通知管理员或采取自动化操作。
  5. 电子商务和推荐系统:Elasticsearch可以用于构建电子商务平台的产品搜索和推荐系统。通过利用其全文搜索和相关性算法,可以提供准确的搜索结果和个性化的推荐体验。

2.3 生产环境的实际应用

许多知名公司和机构在生产环境中使用Elasticsearch,以下是其中的一些例子:

  1. Netflix:使用Elasticsearch进行实时监控和
    分析,以支持其视频流媒体平台的运营和故障排除。
  2. GitHub:将Elasticsearch与Kibana集成,用于存储和分析大量的日志数据,以监控系统性能和应用程序行为。
  3. Uber:利用Elasticsearch和Kibana构建实时监控系统,用于跟踪乘客和司机位置、交通状况等。
  4. Stack Overflow:使用Elasticsearch提供强大的全文搜索功能,使用户能够快速找到相关的技术问题和答案。
  5. 美团:在美团点评的搜索引擎中,使用Elasticsearch来支持商家和商品的实时搜索和推荐功能。

这些只是一小部分使用Elasticsearch的公司和机构,该引擎在各个行业中都得到广泛应用,因为它提供了高性能、实时性和灵活性,能够满足各种搜索和分析需求。

3. ES与传统关系型数据库的区别

3.1 数据模型

  • 关系型数据库使用表格结构,具有固定的列和预定义的模式,需要定义表格结构和关系。
  • Elasticsearch使用文档模型,以JSON格式表示数据,每个文档可以具有不同的字段结构,无需预定义模式。这使得数据建模更加灵活且适应非结构化和半结构化数据。

3.2 查询语言

  • 关系型数据库使用结构化查询语言(SQL)进行数据查询和操作。
  • Elasticsearch使用自己的查询语言(Query DSL),支持全文搜索、过滤、聚合、地理位置查询等复杂的搜索和分析操作。它还提供了强大的近实时(near-real-time)搜索和分析能力。

3.3 水平扩展性

  • 关系型数据库通常在单服务器上运行,具有有限的扩展性。要扩展容量和吞吐量,通常需要升级硬件或采用复杂的分片和复制方案。
  • Elasticsearch设计为分布式系统,可以轻松水平扩展。它将数据分片并分布到多个节点上,实现了高可用性、负载均衡和容错性

3.4 实时性能

  • 关系型数据库在大规模数据量或复杂查询时性能可能下降,特别是在涉及多个表和连接操作时。
  • Elasticsearch专注于实时性能,能够在大规模数据集上提供高性能的搜索、聚合和分析,响应时间通常在毫秒级。

3.5 全文检索和全文索引

  • 关系型数据库通常使用索引来提高查询性能,但对于复杂的全文搜索需求,性能可能不佳。
  • Elasticsearch是一个专门为全文搜索和分析设计的引擎,具有内置的全文索引功能,能够高效地处理大量文本数据的搜索和匹配

总体而言,Elasticsearch在数据模型、查询语言、扩展性和实时性能等方面与传统关系型数据库存在显著差异。它更适用于处理非结构化、大规模和实时数据,并提供强大的全文搜索、聚合和分析功能。传统关系型数据库更适合处理结构化数据和复杂的关系查询。选择使用哪种数据库取决于具体的应用需求和数据特点


英文文档学习


What is Elasticsearch? | Elasticsearch Guide [7.9] | Elastic
What is Elasticsearch?

Elasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack. Logstash and Beats facilitate collecting, aggregating, and enriching your data and storing it in Elasticsearch. Kibana enables you to interactively explore, visualize, and share insights into your data and manage and monitor the stack. Elasticsearch is where the indexing, search, and analysis magic happens.

Elasticsearch是Elastic Stack核心的分布式搜索和分析引擎。Logstash和Beats促进了数据的收集、聚合和丰富,并将其存储在Elasticsearch中。Kibana使您能够交互式地探索、可视化和分享数据的见解,并管理和监控整个堆栈。Elasticsearch是索引、搜索和分析的核心。


Elasticsearch provides near real-time search and analytics for all types of data. Whether you have structured or unstructured text, numerical data, or geospatial data, Elasticsearch can efficiently store and index it in a way that supports fast searches. You can go far beyond simple data retrieval and aggregate information to discover trends and patterns in your data. And as your data and query volume grows, the distributed nature of Elasticsearch enables your deployment to grow seamlessly right along with it.

Elasticsearch为各种类型的数据提供几乎实时的搜索和分析功能。无论您拥有结构化还是非结构化文本、数值数据还是地理空间数据,Elasticsearch都可以以支持快速搜索的方式高效地存储和索引数据。您可以超越简单的数据检索,通过聚合信息来发现数据中的趋势和模式。随着数据和查询量的增长,Elasticsearch的分布式特性使得您的部署可以无缝地随之扩展。


While not every problem is a search problem, Elasticsearch offers speed and flexibility to handle data in a wide variety of use cases:

虽然并非每个问题都是搜索问题,但Elasticsearch提供了处理各种用例中数据的速度和灵活性:

  • Add a search box to an app or website
    为应用程序或网站添加搜索框
  • Store and analyze logs, metrics, and security event data
    存储和分析日志、指标和安全事件数据
  • Use machine learning to automatically model the behavior of your data in real time
    使用机器学习实时自动建模数据行为
  • Automate business workflows using Elasticsearch as a storage engine
    使用Elasticsearch作为存储引擎自动化业务工作流程
  • Manage, integrate, and analyze spatial information using Elasticsearch as a geographic information system (GIS)
    管理、集成和分析空间信息使用Elasticsearch作为地理信息系统(GIS)
  • Store and process genetic data using Elasticsearch as a bioinformatics research tool
    使用Elasticsearch作为生物信息学研究工具存储和处理基因数据

We’re continually amazed by the novel ways people use search. But whether your use case is similar to one of these, or you’re using Elasticsearch to tackle a new problem, the way you work with your data, documents, and indices in Elasticsearch is the same.

我们对人们使用搜索的创新方式感到惊叹。但无论您的用例是否类似于这些用例,或者您正在使用Elasticsearch解决新问题,您在Elasticsearch中处理数据、文档和索引的方式是相同的。


英文句子分析


Elasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack

  • 整句翻译:Elasticsearch是Elastic Stack核心的分布式搜索和分析引擎。

  • 翻译分析

    • Elasticsearch: Elasticsearch,翻译为"Elasticsearch",是专有名词,无需翻译。
    • is: 是一个动词,表示状态或性质。
    • distributed: 分布式,形容词,修饰后面的"search and analytics engine"。
    • search and analytics: 搜索和分析,表示Elasticsearch的两个主要功能。
    • engine: 引擎,表示Elasticsearch是一个执行搜索和分析的工具。
    • at the heart of: 在...的核心,表示Elasticsearch在Elastic Stack的核心位置。
    • the Elastic Stack: Elastic Stack,翻译为"Elastic Stack",是一个专有名词,指代Elasticsearch、Logstash、Beats和Kibana等工具的组合。
  • 语法结构
    主语是"Elasticsearch",谓语是"is",宾语是"distributed search and analytics engine",并且宾语中的"distributed"作为形容词修饰后面的"search and analytics engine"。


Logstash and Beats facilitate collecting, aggregating, and enriching your data and storing it in Elasticsearch.

  • 整句翻译:Logstash和Beats促进了数据的收集、聚合、丰富,并将其存储在Elasticsearch中。

  • 语法分析:

    • facilitate: 动词,表示促进、方便。
    • collecting: 动词的现在分词形式,作为facilitate的宾语,表示收集。
    • aggregating: 动词的现在分词形式,作为facilitate的宾语,表示聚合
    • enriching: 动词的现在分词形式,作为facilitate的宾语,表示丰富
    • your: 代词,表示你的。
    • data: 名词,表示数据。。
    • storing: 动词的现在分词形式,作为facilitate的宾语,表示存储。
    • it: 代词,指代前面提到的数据。
    • in: 介词,表示在…之中。
  • 语法结构:
    主语:Logstash and Beats
    谓语:facilitate
    宾语:collecting, aggregating, and enriching your data and storing it in Elasticsearch


Kibana enables you to interactively explore, visualize, and share insights into your data and manage and monitor the stack.

  • 整句翻译:Kibana使您能够以交互方式探索、可视化和共享数据洞察,并管理和监控整个堆栈。

  • 语法分析

    • Kibana: 专有名词,表示一种数据分析和可视化工具,无需翻译。
    • enables: 动词,表示使能够、使具备。
    • interactively: 副词,表示以交互方式
    • explore: 动词,表示探索、研究。
    • visualize: 动词,表示可视化、图形化。
    • share: 动词,表示共享、分享。
    • insights: 名词,表示洞察、见解。
    • into: 介词,表示进入、到达。
    • and: 连词,连接share和manage
    • manage: 动词,表示管理。
    • monitor: 动词,表示监控
    • stack: 名词,表示堆栈。
  • 语法结构:
    主语:Kibana
    谓语:enables
    宾语:you to interactively explore, visualize, and share insights into your data and manage and monitor the stack


Elasticsearch is where the indexing, search, and analysis magic happens.

  • 整句翻译:Elasticsearch是索引、搜索和分析的魔力发生的地方。

  • 句子结构分析

    • Elasticsearch: 主语,表示一个工具或系统,无需翻译。
    • is: 系动词,表示是。
    • where: 关系副词,引导一个从句,表示地点或情况。
    • the indexing, search, and analysis magic: 名词短语,表示索引、搜索和分析的魔力。
    • happens: 谓语动词,表示发生。
  • 句子结构
    主语:Elasticsearch
    系动词:is
    从句:where the indexing, search, and analysis magic happens


Elasticsearch provides near real-time search and analytics for all types of data.

  • 整句翻译:Elasticsearch提供了适用于所有类型数据的近实时搜索和分析。

  • 句子结构分析

    • Elasticsearch: 主语,表示一个工具或系统,无需翻译。
    • provides: 谓语动词,表示提供
    • near real-time search and analytics: 名词短语,表示近实时搜索和分析。
    • for all types of data: 介词短语,表示适用于所有类型的数据。
  • 句子结构
    主语:Elasticsearch
    谓语动词:provides
    宾语:near real-time search and analytics
    介词短语:for all types of data


Whether you have structured or unstructured text, numerical data, or geospatial data, Elasticsearch can efficiently store and index it in a way that supports fast searches.

  • 整句翻译:无论您拥有结构化或非结构化的文本、数值数据还是地理空间数据,Elasticsearch都可以以一种支持快速搜索的方式高效地存储和索引它们。。

  • 句子结构分析:

    • Whether: 连词,引导一个条件从句。
    • you have structured or unstructured text, numerical data, or geospatial data: 名词短语,表示不同类型的数据。
    • Elasticsearch: 主语,表示一个工具或系统,无需翻译。
    • can efficiently store and index it: 谓语动词短语,表示能够高效地存储和索引。
    • in a way: 介词短语,表示以某种方式。
    • that supports fast searches: 定语从句,修饰in a way,表示支持快速搜索。
  • 句子结构:
    主语:Elasticsearch
    谓语动词短语:can efficiently store and index it
    介词短语:in a way
    定语从句:that supports fast searches

You can go far beyond simple data retrieval and aggregate information to discover trends and patterns in your data. And as your data and query volume grows, the distributed nature of Elasticsearch enables your deployment to grow seamlessly right along with it.

  • 整句翻译:您可以超越简单的数据检索和聚合信息,以发现数据中的趋势和模式。随着您的数据和查询量增长,Elasticsearch的分布式特性使得您的部署可以与之无缝地扩展。

  • 句子结构分析:

    • You: 主语,表示一个人或一组人,无需翻译。
    • can go far beyond simple data retrieval and aggregate information: 谓语动词短语,表示可以超越简单的数据检索和聚合信息。
    • to discover trends and patterns in your data: 不定式短语,作为动词短语的目的状语,表示发现数据中的趋势和模式
    • And: 连词,表示并列关系。
    • as your data and query volume grows: 从句,引导一个时间状语从句,表示随着您的数据和查询量增长。
    • the distributed nature of Elasticsearch enables your deployment to grow seamlessly right along with it: 主语从句,表示Elasticsearch的分布式特性使得您的部署可以与之无缝地扩展。
  • 句子结构分析:
    主语:You
    谓语动词短语:can go far beyond simple data retrieval and aggregate information
    不定式短语:to discover trends and patterns in your data
    连词:And
    从句:as your data and query volume grows
    主语从句:the distributed nature of Elasticsearch enables your deployment to grow seamlessly right along with it

猜你喜欢

转载自blog.csdn.net/qq_29864051/article/details/131426118