最大的特点:
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

http://bbs.csdn.net/topics/300052325

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

  1. Elasticsearch SQL用法详解

    Elasticsearch SQL用法详解  mp.weixin.qq.com 本文详细介绍了不同版本中Elasticsearch SQL的使用方法,总结了实际中常用的方法和操作,并给出了几个具体例子 ...

  2. Elasticsearch match_phrase用法

    目前有用到的用法如下: post /index_name/_search { "query" : { "match_phrase": { "nickn ...

  3. Elasticsearch常见用法-入门

    前台启动 默认是只有本地可以访问 ./bin/elasticsearch 远程访问 修改elasticsearch.yml,把network.host(注意配置文件格式不是以 # 开头的要空一格, : ...

  4. Elasticsearch基本用法(2)--Spring Data Elasticsearch

    Spring Data Elasticsearch是Spring Data项目下的一个子模块. 查看 Spring Data的官网:http://projects.spring.io/spring-d ...

  5. Elasticsearch基本用法(1)--原生操作

    2.2.创建索引 2.2.1.语法 创建索引的请求格式: 请求方式:PUT 请求路径:/索引库名 请求参数:json格式: { "settings": { "number ...

  6. rails elasticsearch searchkick用法

    1.安装elasticsearch 之前要先安装java8: 参考https://www.elastic.co/guide/en/elasticsearch/reference/current/zip ...

  7. Elasticsearch常见用法-分布式集群

    集群内部工作方式 Elasticsearch用于构建高可用和可扩展的系统.扩展的方式可以是购买更好的服务器(纵向扩展(vertical scale or scaling up))或者购买更多的服务器( ...

  8. elasticsearch 基本用法

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

  9. ElasticSearch使用spring-data-elasticSearch的用法

    spring-data-Elasticsearch 使用之前,必须先确定版本,elasticsearch 对版本的要求比较高. spring和elasticsearch有两种链接方式,一种是用TCP协 ...

随机推荐

  1. 权威指南之脚本化jquery

    jqury函数 jquery()($())有4种不同的调用方式 第一种是最常用的调用方式是传递css选择器(字符串)给$()方法.当通过这种方式调用时,$()方法会返回当前文档中匹配该选择器的元素集. ...

  2. 权威指南学习心得-浏览器中的js

    window对象:表示web了浏览器的一个窗口或窗体(winow属性引用自身) 含有以下属性:location包含Location对象,指定当前显示在窗口中URL,允许脚本往窗口里载入新的URL 含有 ...

  3. BZOJ 4311: 向量( 按时间分治 + 线段树 )

    离线, 然后按时间分治, 每个向量都有出现时间[l, r], 直接插入时间线段树(一个向量只会影响O(logN)数量级的线段树节点). 在线段树每个节点弄出凸壳然后二分. 时间复杂度O(Nlog^2N ...

  4. VC++学习之网络编程中的套接字

    VC++学习之网络编程中的套接字 套接字,简单的说就是通信双方的一种约定,用套接字中的相关函数来完成通信过程.应用层通过传输层进行数据通信时,TCP和UDP会遇到同时为多个应用程序进程提供并发服务的问 ...

  5. JQurey获取radio和checkbox的值

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Web2.aspx.cs&q ...

  6. 根据不同需求跳转不同Activity的另外一种写法

    代码如下: /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera <marek.sebera@gm ...

  7. 星际地图制作中OB无建筑 退出问题

    星际地图制作中OB玩家没有建筑强制退出问题,目前 用下面的方法解决 ob玩家分到一个组,触发里面 延时几秒 我设置的2秒 KILL掉这个组的建筑就行~

  8. 【LeetCode题意分析&解答】42. Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  9. 7篇Model View和4篇双缓冲

    http://www.cnblogs.com/SkylineSoft/category/299475.html

  10. hdoj 5319 Painter(模拟题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5319 思路分析:假设颜色R表示为1,颜色B表示为2,颜色G表示为3,因为数据量较小,采用暴力解法即可, ...