学习 Elasticsearch 敲过的指令

本贴最后更新于 3098 天前,其中的信息可能已经时过境迁

—— from《Elasticsearch: The Definitive Guide》

curl -XGET http://localhost:9200/_count?pretty -d ' { "query":{ "match_all":{} } }' curl -i -XGET http://localhost:9200/ curl -XPUT http://localhost:9200/megacorp/employee/1?pretty -d ' { "first_name":"John", "last_name":"Smith", "age":25, "about":"I love to go rock climbing", "interests":["sports","music"] }' curl -XPUT http://localhost:9200/megacorp/employee/2?pretty -d ' { "first_name":"Jane", "last_name":"Smith", "age":32, "about":"I like to collect rock albums", "interests":["music"] }' curl -XPUT http://localhost:9200/megacorp/employee/3?pretty -d ' { "first_name":"Douglas", "last_name":"Fir", "age":35, "about":"I like to build cabinets", "interests":["forestry"] }' curl -XGET http://localhost:9200/megacorp/employee/1?pretty curl -XGET http://localhost:9200/megacorp/employee/_search?pretty curl -XGET http://localhost:9200/megacorp/employee/_search?q=last_name:Smith&pretty curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "query":{ "match":{ "last_name":"Smith" } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "query":{ "filtered":{ "filter":{ "range":{ "age":{ "gt":30 } } }, "query":{ "match":{ "last_name":"smith" } } } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "query":{ "match":{ "about":"rock climbing" } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "query":{ "match_phrase":{ "about":"rock climbing" } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "query":{ "match_phrase":{ "about":"rock climbing" } }, "highlight":{ "fields":{ "about":{} } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "aggs":{ "all_interests":{ "terms":{ "field":"interests" } } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "query":{ "match":{ "last_name":"smith" } }, "aggs":{ "all_interests":{ "terms":{ "field":"interests" } } } }' curl -XGET http://localhost:9200/megacorp/employee/_search?pretty -d ' { "aggs":{ "all_interests":{ "terms":{ "field":"interests" }, "aggs":{ "avg_age":{ "avg":{ "field":"age" } } } } } }' curl -XGET http://localhost:9200/_cluster/health?pretty curl -XPUT http://localhost:9200/blogs?pretty -d ' { "number_of_shards":3, "number_of_replicas":1 }' curl -XPUT http://localhost:9200/blogs/_settings?pretty -d ' { "number_of_replicas":2 }' curl -XPUT http://localhost:9200/website/blog/123?pretty -d ' { "title":"My first blog entry", "text":"Just trying this out...", "date":"2014/01/01" }' curl -XPOST http://localhost:9200/website/blog/?pretty -d ' { "title":"My second blog entry", "text":"Still trying this out...", "date":"2014/01/01" }' curl -XGET http://localhost:9200/website/blog/123?pretty curl -i -XGET http://localhost:9200/website/blog/124?pretty curl -XGET http://localhost:9200/website/blog/123?pretty&_source=title,text curl -XGET http://localhost:9200/website/blog/123/_source curl -i -XHEAD http://localhost:9200/website/blog/123 curl -i -XHEAD http://localhost:9200/website/blog/124 curl -XPUT http://localhost:9200/website/blog/123?pretty -d ' { "title":"My first blog entry", "text":"I am starting to get the hang of this...", "date":"2014/01/02" }' curl -XDELETE http://localhost:9200/website/blog/123?pretty curl -XPUT http://localhost:9200/website/blog/1/_create?pretty -d ' { "title":"My first blog entry", "text":"Just trying this out..." }' curl -XGET http://localhost:9200/website/blog/1?pretty curl -XPUT http://localhost:9200/website/blog/1?version=1&pretty -d ' { "title":"My first blog entry", "text":"starting to get the hang of this..." }' curl -XPUT http://localhost:9200/website/blog/2?version=5&version_type=external&pretty -d ' { "title":"My first external blog entry", "text":"Starting to get the hang of this..." }' curl -XPUT http://localhost:9200/website/blog/2?version=10&version_type=external&pretty -d ' { "title":"My first external blog entry", "text":"This is a piece of cake..." }' curl -XPOST http://localhost:9200/website/blog/1/_update?pretty -d ' { "doc":{ "tags":["testing"], "views":0 } }' curl -XPOST http://localhost:9200/website/blog/1/_update?pretty -d ' { "script":"ctx._source.views+=1" }' curl -XPOST http://localhost:9200/website/blog/1/_update?pretty -d ' { "script":"ctx._source.tags+=new_tag", "params":{ "new_tag":"search" } }' curl -XPOST http://localhost:9200/website/blog/1/_update?pretty -d ' { "script":"ctx.op = ctx._source.views == count ? '"'"'delete'"'"' : '"'"'none'"'", "params":{ "count":1 } }' curl -XPOST http://localhost:9200/website/pageviews/1/_update?pretty -d ' { "script":"ctx._source.views+=1", "upsert":{ "views":1 } }' curl -XPOST http://localhost:9200/website/pageviews/1/_update?pretty&retry_on_conflict=5 -d ' { "script":"ctx._source.views+=1", "upsert":{ "views":0 } }' curl -XGET http://localhost:9200/_mget?pretty -d ' { "docs":[ { "_index":"website", "_type":"blog", "_id":2 }, { "_index":"website", "_type":"pageviews", "_id":1, "_source":"views" } ] }' curl -XGET http://localhost:9200/website/blog/_mget?pretty -d ' { "docs":[ { "_id":2 }, { "_type":"pageviews", "_id":1 } ] }' curl -XGET http://localhost:9200/website/blog/_mget?pretty -d ' { "ids":["2","1"] }' curl -XPOST http://localhost:9200/_bulk?pretty -d ' {"delete":{"_index":"website","_type":"blog","_id":"123"}} {"create":{"_index":"website","_type":"blog","_id":"123"}} {"title":"My first blog post"} {"index":{"_index":"website","_type":"blog"}} {"title":"My second blog post"} {"update":{"_index":"website","_type":"blog","_id":"123","_retry_on_conflict":3}} {"doc":{"title":"My updated blog post"}} ' curl -XPOST http://localhost:9200/_bulk?pretty -d ' {"create":{"_index":"website","_type":"blog","_id":"123"}} {"title":"Cannot create - it already exists"} {"index":{"_index":"website","_type":"blog","_id":"123"}} {"title":"But we can update it"} ' curl -XPOST http://localhost:9200/website/_bulk?pretty -d ' {"index":{"_type":"log"}} {"event":"User logged in"} ' curl -XPOST http://localhost:9200/website/log/_bulk?pretty -d ' {"index":{}} {"event":"User logged in"} {"index":{"_type":"blog"}} {"title":"Overriding the default type"} ' curl -XGET http://localhost:9200/_search\?pretty curl -XGET http://localhost:9200/_search?pretty&size=10&from=10 curl -XGET http://localhost:9200/gb/_mapping/tweet curl -XGET http://lcoalhost:9200/ikyxxs/_mapping/faq?pretty curl -XFELETE http://localhost:9200/gb curl -XPUT http://localhost:9200/gb?pretty -d ' { "mappings":{ "tweet":{ "properties":{ "tweet":{ "type":"string", "analyzer":"english" }, "date":{ "type":"date" }, "name":{ "type":"string" }, "user_id":{ "type":"long" } } } } }' curl -XPUT http://localhost:9200/gb_mapping/tweeet -d ' { "properties":{ "tag":{ "type":"string", "index":"not_analyzed" } } }' curl -XGET http://localhost:9200/gb/_analyze?field=tweet&pretty -d ' Black-cats' curl -XGET http://localhost:9200/gb/_analyze?field=tag?pretty -d ' Black-cats' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "match_all":{} } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "match":{ "tweet":"elasticsearch" } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "filtered":{ "query":{ "match_all":{} }, "filter":{ "term":{ "folder":"inbox" } } } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "filtered":{ "filter":{ "bool":{ "must":{ "term":{ "folder":"inbox" } }, "must_not":{ "query":{ "match":{ "email":"urgent business proposal" } } } } } } } }' curl -XGET http://localhost:9200/gb/tweet/_validate/query?pretty -d ' { "query":{ "tweet":{ "match":"really powerful" } } }' curl -XGET http://localhost:9200/gb/tweet/_validate/query?explain&pretty -d ' { "query":{ "tweet":{ "match":"really powerful" } } }' curl -XGET http://localhost:9200/_validate/query?explain&pretty -d ' { "query":{ "match":{ "tweet":"really powerful" } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "filtered":{ "filter":{ "term":{ "user_id":1 } } } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "filtered":{ "filter":{ "term":{ "user_id":1 } } } }, "sort":{ "date":{ "order":"desc" } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "filtered":{ "query":{ "match":{ "tweet":"manage text search" } }, "filter":{ "term":{ "user_id":2 } } } }, "sort":[ { "date":{ "order":"desc" } }, { "_score":{ "order":desc } } ] }' curl -XGET http://localhost:9200/_search?pretty&sort=date:desc&sort=_score&q=search curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "match":{ "tweet":"elasticsearch" } }, "sort":"tweet.raw" }' curl -XGET http://localhost:9200/_search?pretty&explain -d ' { "query":{ "match":{ "tweet":"honeymoon" } } }' curl -XGET http://localhost:9200/us/tweet/12/_explain -d ' { "query":{ "filtered":{ "filter":{ "term":{ "user_id":2 } }, "query":{ "match":{ "tweet":"honeymoon" } } } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "from":90, "size":10 }' curl -XGET http://localhost:9200/_search?pretty&routing=user_1,user2 curl -XGET http://localhost:9200/_search?pretty&search_type=count curl -XGET http://localhost:9200/old_index/_search?search_type=scan&scroll=1m -d ' { "query":{ "match_all":{} }, "size":1000 }' curl -XDELETE http://localhost:9200/my_index curl -XDELETE http://localhost:9200/index_one,index_two curl -XDELETE http://localhost:9200/index_* curl -XDELETE http://localhost:9200/_all curl -XPUT http://localhost:9200/my_temp_index?pretty -d ' { "settings":{ "number_of_shards": 1, "number_of_replicas": 0 } }' curl -XPUT http://localhost:9200/my_temp_index/_settings?pretty -d ' { "number_of_replicas": 1 }' curl -XPUT http://localhost:9200/spanish_docs?pretty -d ' { "settings":{ "analysis":{ "anlayzer":{ "es_std":{ "type":"standard", "stopwords":"_spanish_" } } } } }' curl -XGET http://localhost:9200/spanish_docs/_analyze?pretty&analyzer=es_std -d ' El veloz zorro marron' curl -XPUT http://localhost:9200/my_index?pretty -d ' { "settings":{ "analysis":{ "char_filter":{ "&_to_and":{ "type":"mapping", "mappings":["&=> and"] } }, "filter":{ "my_stopwords":{ "type":"stop", "stopwords":["the","a"] } }, "analyzer":{ "my_analyzer":{ "type":"custom", "char_filter":["html_strip", "&_to_end"], "tokenizer":"standard", "filter":["lowercase", "my_stopwords"] } } } } }' curl -XGET http://localhost:9200/my_index/_analyze?analyzer=my_analyzer?pretty -d ' The quick & brown fox' curl -XPUT http://localhost:9200/my_index/_mapping/my_type?pretty -d ' { "properties":{ "title":{ "type":"string", "analyzer":"my_analyzer" } } }' curl -XGET http://localhost:9200/_seach?pretty -d ' { "query":{ "match":{ "title":"The quick brown fox" } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "multi_match":{ "query":"The quick brown fox", "fields":["blog_en.title", "blog_es.title"] } } }' curl -XPUT http://localhost:9200/my_index?prertty -d ' { "mappings":{ "my_type":{ "_source":{ "ebable":false } } } }' curl -XGET http://localhost:9200/_search?pretty -d ' { "query":{ "match_all":{} }, "_source":["title", "created"] }' curl -XGET http://localhost:9200/_search?pretty -d ' { "match":{ "_all": "john smith marketing" } }' curl -XPUT http://localhost:9200/my_index/_mapping/my_type?pretty -d ' { "my_type":{ "_all": { "enabled":false } } }' curl -XPUT http://localhost:9200/my_index/my_type/_mapping?pretty -d ' { "my_type":{ "_all": { "analyzer":"whitespace" } } }' curl -XPUT http://localhost:9200/my_index?pretty -d ' { "mapping":{ "my_type":{ "_id":{ "path":"doc_id" }, "properties":{ "doc_id":{ "type":"string", "index":"not_analyzed" } } } } }' curl -XPOST http://localhost:9200/my_index/my_type?pretty -d ' { "doc_id":"123" }'
  • Elasticsearch

    Elasticsearch 是一个基于 Lucene 的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于 RESTful 接口。Elasticsearch 是用 Java 开发的,并作为 Apache 许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。

    117 引用 • 99 回帖 • 204 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
mubai
洛阳亲友如相问,就说我在写代码 杭州

推荐标签 标签

  • Python

    Python 是一种面向对象、直译式电脑编程语言,具有近二十年的发展历史,成熟且稳定。它包含了一组完善而且容易理解的标准库,能够轻松完成很多常见的任务。它的语法简捷和清晰,尽量使用无异义的英语单词,与其它大多数程序设计语言使用大括号不一样,它使用缩进来定义语句块。

    556 引用 • 675 回帖
  • JRebel

    JRebel 是一款 Java 虚拟机插件,它使得 Java 程序员能在不进行重部署的情况下,即时看到代码的改变对一个应用程序带来的影响。

    26 引用 • 78 回帖 • 676 关注
  • Maven

    Maven 是基于项目对象模型(POM)、通过一小段描述信息来管理项目的构建、报告和文档的软件项目管理工具。

    188 引用 • 319 回帖 • 252 关注
  • RabbitMQ

    RabbitMQ 是一个开源的 AMQP 实现,服务器端用 Erlang 语言编写,支持多种语言客户端,如:Python、Ruby、.NET、Java、C、PHP、ActionScript 等。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面表现不俗。

    49 引用 • 60 回帖 • 342 关注
  • OkHttp

    OkHttp 是一款 HTTP & HTTP/2 客户端库,专为 Android 和 Java 应用打造。

    16 引用 • 6 回帖 • 85 关注
  • Solidity

    Solidity 是一种智能合约高级语言,运行在 [以太坊] 虚拟机(EVM)之上。它的语法接近于 JavaScript,是一种面向对象的语言。

    3 引用 • 18 回帖 • 437 关注
  • 正则表达式

    正则表达式(Regular Expression)使用单个字符串来描述、匹配一系列遵循某个句法规则的字符串。

    31 引用 • 94 回帖 • 1 关注
  • Ant-Design

    Ant Design 是服务于企业级产品的设计体系,基于确定和自然的设计价值观上的模块化解决方案,让设计者和开发者专注于更好的用户体验。

    17 引用 • 23 回帖 • 1 关注
  • 房星科技

    房星网,我们不和没有钱的程序员谈理想,我们要让程序员又有理想又有钱。我们有雄厚的房地产行业线下资源,遍布昆明全城的 100 家门店、四千地产经纪人是我们坚实的后盾。

    6 引用 • 141 回帖 • 592 关注
  • 生活

    生活是指人类生存过程中的各项活动的总和,范畴较广,一般指为幸福的意义而存在。生活实际上是对人生的一种诠释。生活包括人类在社会中与自己息息相关的日常活动和心理影射。

    230 引用 • 1454 回帖
  • 周末

    星期六到星期天晚,实行五天工作制后,指每周的最后两天。再过几年可能就是三天了。

    14 引用 • 297 回帖 • 1 关注
  • LeetCode

    LeetCode(力扣)是一个全球极客挚爱的高质量技术成长平台,想要学习和提升专业能力从这里开始,充足技术干货等你来啃,轻松拿下 Dream Offer!

    209 引用 • 72 回帖
  • WiFiDog

    WiFiDog 是一套开源的无线热点认证管理工具,主要功能包括:位置相关的内容递送;用户认证和授权;集中式网络监控。

    1 引用 • 7 回帖 • 609 关注
  • Electron

    Electron 基于 Chromium 和 Node.js,让你可以使用 HTML、CSS 和 JavaScript 构建应用。它是一个由 GitHub 及众多贡献者组成的活跃社区共同维护的开源项目,兼容 Mac、Windows 和 Linux,它构建的应用可在这三个操作系统上面运行。

    15 引用 • 136 回帖 • 4 关注
  • WebComponents

    Web Components 是 W3C 定义的标准,它给了前端开发者扩展浏览器标签的能力,可以方便地定制可复用组件,更好的进行模块化开发,解放了前端开发者的生产力。

    1 引用 • 9 关注
  • Angular

    AngularAngularJS 的新版本。

    26 引用 • 66 回帖 • 549 关注
  • uTools

    uTools 是一个极简、插件化、跨平台的现代桌面软件。通过自由选配丰富的插件,打造你得心应手的工具集合。

    7 引用 • 27 回帖
  • AngularJS

    AngularJS 诞生于 2009 年,由 Misko Hevery 等人创建,后为 Google 所收购。是一款优秀的前端 JS 框架,已经被用于 Google 的多款产品当中。AngularJS 有着诸多特性,最为核心的是:MVC、模块化、自动化双向数据绑定、语义化标签、依赖注入等。2.0 版本后已经改名为 Angular。

    12 引用 • 50 回帖 • 507 关注
  • JavaScript

    JavaScript 一种动态类型、弱类型、基于原型的直译式脚本语言,内置支持类型。它的解释器被称为 JavaScript 引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在 HTML 网页上使用,用来给 HTML 网页增加动态功能。

    730 引用 • 1280 回帖 • 5 关注
  • 招聘

    哪里都缺人,哪里都不缺人。

    188 引用 • 1057 回帖
  • Q&A

    提问之前请先看《提问的智慧》,好的问题比好的答案更有价值。

    9705 引用 • 44150 回帖 • 90 关注
  • LaTeX

    LaTeX(音译“拉泰赫”)是一种基于 ΤΕΧ 的排版系统,由美国计算机学家莱斯利·兰伯特(Leslie Lamport)在 20 世纪 80 年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由 TeX 所提供的强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。

    12 引用 • 54 回帖 • 8 关注
  • IPFS

    IPFS(InterPlanetary File System,星际文件系统)是永久的、去中心化保存和共享文件的方法,这是一种内容可寻址、版本化、点对点超媒体的分布式协议。请浏览 IPFS 入门笔记了解更多细节。

    21 引用 • 245 回帖 • 228 关注
  • 印象笔记
    3 引用 • 16 回帖 • 2 关注
  • jsoup

    jsoup 是一款 Java 的 HTML 解析器,可直接解析某个 URL 地址、HTML 文本内容。它提供了一套非常省力的 API,可通过 DOM,CSS 以及类似于 jQuery 的操作方法来取出和操作数据。

    6 引用 • 1 回帖 • 487 关注
  • 链滴

    链滴是一个记录生活的地方。

    记录生活,连接点滴

    174 引用 • 3852 回帖
  • Sphinx

    Sphinx 是一个基于 SQL 的全文检索引擎,可以结合 MySQL、PostgreSQL 做全文搜索,它可以提供比数据库本身更专业的搜索功能,使得应用程序更容易实现专业化的全文检索。

    1 引用 • 224 关注