• 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]$ 
  • 相关阅读:
    MVC三层架构
    JavaScript,你好!(二)
    HTML你好!
    Typora,你好!
    安装mysqlmysql-5.7.24-linux-glibc2.12-x86_64
    sizeof与strlen的区别
    printf格式化输出
    java泛型讲解
    双系统删除Linux系统
    kali破解wifi密码
  • 原文地址:https://www.cnblogs.com/zlslch/p/7101443.html
Copyright © 2020-2023  润新知