开始学习使用 elasticsearch, 把步骤记录在这里:

最大的特点: 
1. 数据库的 database, 就是  index 
2. 数据库的 table,  就是 tag 
3. 不要使用browser, 使用curl来进行客户端操作.  否则会出现 java heap ooxx...

curl:  -X 后面跟 RESTful :  GET, POST ... 
-d 后面跟数据。 (d = data to send)

1. create:

指定 ID 来建立新记录。 (貌似PUT, POST都可以) 
$ curl -XPOST localhost:9200/films/md/2 -d ' 
{ "name":"hei yi ren", "tag": "good"}'

使用自动生成的 ID 建立新纪录: 
$ curl -XPOST localhost:9200/films/md -d ' 
{ "name":"ma da jia si jia3", "tag": "good"}'

2. 查询: 
2.1 查询所有的 index, type: 
$ curl localhost:9200/_search?pretty=true

2.2 查询某个index下所有的type: 
$ curl localhost:9200/films/_search

2.3 查询某个index 下, 某个 type下所有的记录: 
$ curl localhost:9200/films/md/_search?pretty=true

2.4 带有参数的查询:  
$ curl localhost:9200/films/md/_search?q=tag:good 
{"took":7,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"film","_type":"md","_id":"2","_score":1.0, "_source" : 
{ "name":"hei yi ren", "tag": "good"}},{"_index":"film","_type":"md","_id":"1","_score":0.30685282, "_source" : 
{ "name":"ma da jia si jia", "tag": "good"}}]}}

2.5 使用JSON参数的查询: (注意 query 和 term 关键字) 
$ curl localhost:9200/film/_search -d ' 
{"query" : { "term": { "tag":"bad"}}}'

3. update  
$ curl -XPUT localhost:9200/films/md/1 -d { ...(data)... }

4. 删除。 删除所有的: 
$ curl -XDELETE localhost:9200/films

elasticsearch的基本用法的更多相关文章

  1. ElasticSearch的基本用法与集群搭建

    一.简介 ElasticSearch和Solr都是基于Lucene的搜索引擎,不过ElasticSearch天生支持分布式,而Solr是4.0版本后的SolrCloud才是分布式版本,Solr的分布式 ...

  2. Elasticsearch批量操作API用法介绍

    Elasticsearch的Bulk API允许批量提交index和delete请求,有如下两种用法: 用法1 BulkRequestBuilder requestBuilder = client.p ...

  3. ElasticSearch的基本用法与集群搭建 good

    一.简介 ElasticSearch和Solr都是基于Lucene的搜索引擎,不过ElasticSearch天生支持分布式,而Solr是4.0版本后的SolrCloud才是分布式版本,Solr的分布式 ...

  4. 中间件:ElasticSearch组件RestHighLevelClient用法详解

    本文源码:GitHub·点这里 || GitEE·点这里 一.基础API简介 1.RestHighLevelClient RestHighLevelClient的API作为ElasticSearch备 ...

  5. elasticsearch的基本用法(转载)

    本文出自:http://blog.csdn.net/feelig/article/details/8499614 最大的特点:  1. 数据库的 database, 就是  index  2. 数据库 ...

  6. elasticsearch 映射 dynamic用法

  7. Elasticsearch之java的基本操作一

    摘要   接触ElasticSearch已经有一段了.在这期间,遇到很多问题,但在最后自己的不断探索下解决了这些问题.看到网上或多或少的都有一些介绍ElasticSearch相关知识的文档,但个人觉得 ...

  8. Elasticsearch+Logstash+Kibana教程

    参考资料 累了就听会歌吧! Elasticsearch中文参考文档 Elasticsearch官方文档 Elasticsearch 其他——那些年遇到的坑 Elasticsearch 管理文档 Ela ...

  9. Elasticsearch是一个分布式可扩展的实时搜索和分析引擎,elasticsearch安装配置及中文分词

    http://fuxiaopang.gitbooks.io/learnelasticsearch/content/  (中文) 在Elasticsearch中,文档术语一种类型(type),各种各样的 ...

随机推荐

  1. Delphi XE10让android的界面设计摆脱繁杂

    设计一个选项卡. 大体图样: 1.创建一个multi_Device_Application;2.在form上放一个Rectangle1,设置align为top.设置fill属性的kind为Gradie ...

  2. Matlab心得及学习方法(不断更新)

    Matlab心得及学习方法(不断更新) Matlab心得及学习方法(不断更新)P.S. 那些网上转载我的文章不写明出处的傻眼了吧?!老子更新了! 发现现在很多人(找工作的或者读博的)都想要学习或者正在 ...

  3. 部分视图调用方法总结(Action 、 RenderAction 、 Partial 、 RenderPartial)

    Action . RenderAction . Partial . RenderPartial 1.Action . RenderAction Action 方法以字符串的形式返回子视图,可以直接被呈 ...

  4. pmtest1.asm pmtest2.asm pmtest5.asm 这几个比较重要.

    读代码时注意Label后面的文字:desc表示是描述符,seg表示是段 pmtest1.asm 主要讲进入保护模式 http://www.cnblogs.com/wanghj-dz/archive/2 ...

  5. Delphi实现多个图像相互覆盖时无内容处点击穿透

    http://www.52delphi.com/list.asp?ID=1405 CM_HITTEST是Delphi自定义的控件消息

  6. CP_THREAD_ACP与CP_ACP

    在使用MultiByteToWideChar的时候,大部分都知道上述两个参数,MSDN上的解释也是简单到极致.通常我们会选择使用CP_ACP,但是总有人会在没有真正明白它们之间的区别前使用CP_THR ...

  7. vijosP1567子串计数

    描述现在有一个字符串,请求出这个字符串不相同的子串个数.YXY现在不会做,请你来帮忙…… n<=20W 题解: 后缀数组裸题,其实我在练习模板写对了没 代码: #include<cstdi ...

  8. [HDU 1565+1569] 方格取数

    HDU 1565 方格取数(1) Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  9. Xcode6新建的工程没有Frameworks文件夹了?!原来是这样

    http://stackoverflow.com/questions/24181062/default-frameworks-missing-in-xcode-6-beta They are impo ...

  10. 【转】win7与VMware ubuntu虚拟机实现文件共享(最后一定要装open-vm-dkms插件)

    原文网址:http://blog.sina.com.cn/s/blog_453b9efb01019hpl.html 一般来说,由于一些特殊的需要,会在Win7系统中利用虚拟机(VMware)安装ubu ...