首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我想我不太懂弹性搜索

我想我不太懂弹性搜索
EN

Stack Overflow用户
提问于 2016-04-14 18:49:19
回答 1查看 84关注 0票数 1

我想了解一些关于弹性搜索的东西,想知道是否有人能帮我找出答案。

我面临的问题是,我应该维持多少个指数,如果存在太多的风险。让我说,我想在图书馆中索引书籍,并希望能够搜索:

  • 作者
  • CHapter名称
  • 书名
  • 出版商

据我所知,ES是一个文档存储引擎,这意味着数据类型是存储的,而不是标准化的RDMS结构。复杂的是,我是创建一种数据类型并将其存储,还是应该创建其他数据类型?

如何存储数据以便能够搜索以下组合:

  1. 按Publisher X分列的所有作者
  2. 书名中的所有章节名称以B开头,由出版商Y开始
  3. 所有作者X所写书籍的出版商,其名称为Y章

我想知道我是否必须为每一章创建一个索引,然后每一章都有一个所有出版商的列表,这些出版商都有这本书的特征。

我把事情复杂化了吗?

EN

回答 1

Stack Overflow用户

发布于 2016-04-14 19:07:28

根据我在您的问题中看到的,您只需要创建一个索引(MySQL中的数据库模拟),在这个索引中您将需要使用内容类型(如MySQL中的表),并且每本书都是数据类型内的文档(如MySQL中的行)。

你可以像这样添加你的书

代码语言:javascript
复制
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"
}

您可以按任何字段搜索文档。

代码语言:javascript
复制
POST library/books/_search
{
  "query": {
    "term": {
      "language": {
        "value": "english"
      }
    }
  }
}

或任何字段组合

代码语言:javascript
复制
POST library/books/_search
{
  "query": {
    "bool": {
      "should": [
        {"term": {
          "language": {
            "value": "english"
          }
        }},
        {"term": {
          "type": {
            "value": "paperback"
          }
        }}
      ]
    }
  }
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36631554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档