全文检索必备:一些常用的ElasticSearch查询语句.pdf

全文检索必备:一些常用的ElasticSearch查询语句.pdf

  1. 1、本文档共25页,可阅读全部内容。
  2. 2、本文档付费后,不意味着付费购买了版权,只能用于单位或个人使用,不得用于商业用途(如:【转卖】进行直接盈利和【编辑后售卖】进行间接盈利)。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:18428362892(电话支持时间:9:00-19:00)。
常用ElasticSearch 查询语句参考 为了演示不同类型的 ElasticSearch 的查询,我们将使用书文档信息的集合(有以下字段: title (标题), authors (作者), summary (摘要), publish_date (发布日期)和 num_reviews (浏览数))。 在这之前,首先我们应该先创建一个新的索引(index),并批量导入一些文档: 创建索引: PUT /bookdb_index { "settings": { "number_of_shards": 1 }} 批量上传文档: POST /bookdb_index/book/_bulk { "index": { "_id": 1 }} { "title": "Elasticsearch: The Definitive Guide", "authors": ["clinton gormley", "zachary tong"], "summary" : "A distibuted real-time search and analytics engine", "publish_date" : "2015-02-07", "num_reviews": 20, "publisher": "oreilly" } { "index": { "_id": 2 }} { "title": "Taming Text: How to Find, Organize, and Manipulate It", "authors": ["grant ingersoll", "thomas morton", "drew farris"], "summary" : "organize text using approaches such as full-text search, proper name recognition, clustering, tagging, information extraction, and summarization", "publish_date" : "2013-01-24", "num_reviews": 12, "publisher": "manning" } { "index": { "_id": 3 }} { "title": "Elasticsearch in Action", "authors": ["radu gheorge", "matthew lee hinman", "roy russo"], "summary" : "build scalable search applications using Elasticsearch without having to do complex low-level programming or understand advanced data science algorithms", "publish_date" : "2015-12-03", "num_reviews": 18, "publisher": "manning" } { "index": { "_id": 4 }} { "title": "Solr in Action", "authors": ["trey grainger", "timothy potter"], "summary" : "Comprehensive guide to implementing a scalable search engine using Apache Solr", "publish_date" : "2014-04-05", "num_reviews": 23, "publisher": "manning" } 栗子: 1. 基本的匹配(Query)查询 有两种方式来执行一个全文匹配查询: 使用 Search Lite API,它从 url 中读取所有的查询参数 使用完整 JSON 作为请求体,这样你可以使用完整的 Elasticsearch DSL 下面是一个基本的匹配查询,查询任一字段包含 Guide 的记录 GET /bookdb_index/book/_search?q=guide [Results] "hits": [ { "_index": "bookdb_index", "_type": "book",

您可能关注的文档

文档评论(0)

136****0621

相关文档

相关课程推荐