zoukankan      html  css  js  c++  java
  • elasticsearch 的使用 查询操作

    elasticsearch的查询方法

    创建索引

    PUT test1

    添加数据,可以指定id

    POST test1/_doc/2 { "name":"刘备", "age":54, "location":"蜀国" }

    查询操作两种方法

    · 第一种
    GET test1/_search?q=location="吴国"

    · 第二种DSL查询方式
    GET test1/_search { "query": { "match": { "location": "吴国" } } }
    这种方式查询的是对location进行了分词,吴国分为了三个:吴、国、吴国
    如果加上.keyword 则表示对location该词语不进行分词 完全搜索
    GET test1/_search { "query": { "match": { "location.keyword": "吴国" } } }

    还有一个类似于mysql中select * from tables;

    类似于select * from tables;

    GET test1/_search { "query": { "match_all": {} } }

    查询结果排序

    GET test1/_search { "query": { "match": { "location.keyword": "蜀国" } }, "sort": [ { "age": { "order": "desc" } } ] }

    如果是要选择升序,就使用asc

  • 相关阅读:
    CF 234 C Weather(粗暴方法)
    给工作赋予的新意义——Leo鉴书78
    获取集合的方法
    VS 统计代码行数
    , ,
    指针的删除动作
    C++ 名称空间
    boost::token_compress_on
    指针与引用
    容器的end()方法
  • 原文地址:https://www.cnblogs.com/ch2020/p/15641380.html
Copyright © 2011-2022 走看看