最大的特点:
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 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. Codeforces Round #359 (Div. 2) B

    B. Little Robber Girl's Zoo time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. 我对webform的整改。

    对于webfom,一种写法,将所有业务单元封装在一个pagebase里面,所有的页面继承自pagebase这个service外观,这样的结果就是,所有的页面单元上代码量会非常少.最大程度减少耦合,而最 ...

  3. MySQL 5.7主从复制与主主复制实现细节分析

    0.简介: MySQL作为世界上使用最为广泛的数据库之一,免费是其原因之一.但不可忽略的是它本身的功能的确很强大.随着技术的发展,在实际的生产环境中,由单台MySQL数据库服务器不能满足实际的需求.此 ...

  4. GHC extensions

    OverloadedStrings 这是最常见的一个扩展,很多时候都能看到   Haskell中,数字是num的多态,比如:   a :: Int a = 1   b :: Double b = 1 ...

  5. CString::GetLength()获得字节数

    按照MSDN的说吗,在选用MBCS多字节字符串编码时,该方法会得到正确的字节数.此时没有问题. For multibyte character sets (MBCS), GetLength count ...

  6. 关闭vs警告

    禁用所有编译器警告 当“解决方案资源管理器”中有项目选中时,在“项目”菜单上单击“属性”. 单击“编译”选项卡. 选中“禁用所有警告”复选框. 禁用单个编译器警告 在“解决方案资源管理器”中选定一个项 ...

  7. ECShop安装实录

    版本: ecmoban_V2.7.3_UTF8_20150623 来源: 官网 一. 给 C:\Windows\temp目录增加 IIS_Users 完全权限. 二. 安装报错: Warning: d ...

  8. Optional int parameter 'rows' is not present but cannot be translated into a null value due to being declared as a primitive type.

    我的spring mvc 代码: @Controller @RequestMapping("/product") public class Fancy { @RequestMapp ...

  9. bash shell 文本文件操作

    一.打开文本文档,查看文本的内容,我们最直观的方式就是用编辑器,并且可以使用vi内部的查找命令查找[参见Vim文字编辑] vi test.txt#使用vi打开当前目录下的test.txt文本 二.总结 ...

  10. Visual Studio跨平台开发(5):Xamarin Android多页面应用开发

    前言 大部份的Android 都具有实体或虚拟的Back键. 因此在处理多页面应用程序时, 与先前所介绍的iOS Navigation controller 比较起来会简单许多. 1. 开启Visua ...