zoukankan      html  css  js  c++  java
  • Elasticsearch之CURL命令的DSL查询

      它是Domain Specific Language领域特定语言。

    https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

       大家,自行先去看。

      新添加一个文档

    [hadoop@master elasticsearch-2.4.0]$ curl -XPUT http://master:9200/zhouls/user/4/_create -d '{"name": "lily" , "age" : 18}' 
    {"_index":"zhouls","_type":"user","_id":"4","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"created":true}[hadoop@master elasticsearch-2.4.0]$ 
    [hadoop@master elasticsearch-2.4.0]$ 
    [hadoop@master elasticsearch-2.4.0]$ 

      得到

      

       更多,大家可以去见官网,如下

    https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html

       复杂的查询,我们通过这种匹配match不同的字段是很有作用的。

    [hadoop@master elasticsearch-2.4.0]$ curl -XGET http://master:9200/zhouls/user/_search -d '{"query" : {"match" : {"name": "lily" }}}' 
    {"took":26,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"zhouls","_type":"user","_id":"4","_score":1.0,"_source":{"name": "lily" , "age" : 18}}]}}[hadoop@master elasticsearch-2.4.0]$ 
    [hadoop@master elasticsearch-2.4.0]$ 
    [hadoop@master elasticsearch-2.4.0]$ curl -XGET http://master:9200/zhouls/user/_search -d '{"query" : {"match" : {"name": "john" }}}' 
    {"took":11,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":4,"max_score":1.0,"hits":[{"_index":"zhouls","_type":"user","_id":"2","_score":1.0,"_source":{"name" : "john"  , "age" : 28}},{"_index":"zhouls","_type":"user","_id":"1","_score":1.0,"_source":{"name" : "john"  , "age" : 28}},{"_index":"zhouls","_type":"user","_id":"AVz5Q9u7U8bDb6QDgbDS","_score":1.0,"_source":{"name" : "john"}},{"_index":"zhouls","_type":"user","_id":"3","_score":0.30685282,"_source":{"name" : "john"  , "age" : 28}}]}}[hadoop@master elasticsearch-2.4.0]$ 
    [hadoop@master elasticsearch-2.4.0]$ 
    [hadoop@master elasticsearch-2.4.0]$ 
  • 相关阅读:
    希腊字母写法
    The ASP.NET MVC request processing line
    lambda aggregation
    UVA 10763 Foreign Exchange
    UVA 10624 Super Number
    UVA 10041 Vito's Family
    UVA 10340 All in All
    UVA 10026 Shoemaker's Problem
    HDU 3683 Gomoku
    UVA 11210 Chinese Mahjong
  • 原文地址:https://www.cnblogs.com/zlslch/p/7101443.html
Copyright © 2011-2022 走看看