elasticsearch - 我不认为我完全了解Elastic Search

标签 elasticsearch

我想了解一些有关Elastic Search的信息,想知道是否有人可以帮助我解决这个问题。

我的问题是我应该维护多少个索引,以及它们中是否有太多的风险。可以说我想为图书馆中的书籍编制索引并希望能够进行搜索:

  • 作者
  • 章名
  • 书名
  • 发布者

  • 据我了解,ES是一个文档存储引擎,这意味着数据类型的存储与标准化RDMS结构相反。我遇到的麻烦是,我是创建一个数据类型并存储该数据类型,还是应该创建其他数据类型?

    我将如何存储数据以能够搜索以下组合:
  • 发布者X的所有作者
  • 书籍名称中以B开头并由出版商Y发行的所有章节名称
  • 作者X撰写的所有书籍的发行者,章节名称为Y

  • 我想知道我是否必须为各章创建索引,然后每章都包含具有该书特色的所有出版商的列表。

    我是否使这个复杂化了?

    最佳答案

    根据我在问题中看到的,您只需要创建一个索引(MySQL中的数据库类似物),在此索引中,您将需要使用内容类型(如MySQL中的表),每本书将是数据类型(如row)中的文档在MySQL中)

    您可以像这样添加您的书

    POST library/books/ISBN-10:1449358543
    {
      "type": "Paperback",
      "pages": 724,
      "Publisher": "O'Reilly Media; 1 edition (Feb. 7 2015)",
      "language": "English",
      "tag": "Elasticsearch: The Definitive Guide Paperback – Feb 7 2015\nby Clinton Gormley (Author), Zachary Tong (Author)",
      "desc": "Whether you need full-text search or real-time analytics of structured data—or both—the Elasticsearch distributed search engine is an ideal way to put your data to work. This practical guide not only shows you how to search, analyze, and explore data with Elasticsearch, but also helps you deal with the complexities of human language, geolocation, and relationships.\nIf you’re a newcomer to both search and distributed systems, you’ll quickly learn how to integrate Elasticsearch into your application. More experienced users will pick up lots of advanced techniques. Throughout the book, you’ll follow a problem-based approach to learn why, when, and how to use Elasticsearch features.\nUnderstand how Elasticsearch interprets data in your documents Index and query your data to take advantage of search concepts such as relevance and word proximity Handle human language through the effective use of analyzers and queries Summarize and group data to show overall trends, with aggregations and analytics Use geo-points and geo-shapes—Elasticsearch’s approaches to geolocation Model your data to take advantage of Elasticsearch’s horizontal scalability Learn how to configure and monitor your cluster in production"
    }
    

    您可以按任何字段搜索文档
    POST library/books/_search
    {
      "query": {
        "term": {
          "language": {
            "value": "english"
          }
        }
      }
    }
    

    或任何字段组合
    POST library/books/_search
    {
      "query": {
        "bool": {
          "should": [
            {"term": {
              "language": {
                "value": "english"
              }
            }},
            {"term": {
              "type": {
                "value": "paperback"
              }
            }}
          ]
        }
      }
    }
    

    关于elasticsearch - 我不认为我完全了解Elastic Search,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36631554/

    相关文章:

    elasticsearch - ElasticSearch根据找到短语的字段对文档进行排序

    ruby-on-rails - ElasticSearch和 cucumber

    elasticsearch - Logstash错误-用于Elasticsearch的未知设置 '“hosts”'

    spring-boot - 使用 NativeSearchQuery 从 Elasticsearch 查询数据时出现问题

    elasticsearch - Elasticsearch类型与具有不同架构的索引

    elasticsearch - Elasticsearch分组依据

    c# - 记录(通过 Serilog)到 ElasticSearch 不起作用

    PHP 和 Elasticsearch 在返回的对象中包含分数/相关性

    elasticsearch - version=1&version_type=external 和 if_seq_no=0&if_primary_term=1 之间的区别

    node.js - Mac OS X Yosemite 上的 ElasticSearch + Node : JRE crash?