gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 22:46:32 24 4
gpt4 key购买 nike

我想了解一些有关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/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com