zoukankan      html  css  js  c++  java
  • elasticsearch常用语句

    elasticsearch常用语句

    基于Kibana工具的DEV Tools

    1、创建索引 plan

    PUT /plan
    { "settings": { "number_of_shards": 1 }}

    2、插入id为6,映射类型为publishedEop的数据

    PUT /plan/publishedEop/6
    {
      "id" : "Mark6",
      "name" : "name",
      "detail" : "I get detail"
    }

    3、删除id为6的数据

    DELETE /plan/publishedEop/6

    4、编辑id为6的数据(覆盖方式)

    PUT /plan/publishedEop/6
    {
      "id" : "Mark6",
      "name" : "name",
      "detail" : "I get detail 更改内容"
    }

    5、查询

    •   查询plan索引publishedEop类型下的全部数据
    GET /plan/publishedEop/_search
    {
      "query": {
        "match_all": {}
      }
    }
    • 查询id为6的数据
    POST /plan/publishedEop/6/_search
    {
      "query": {
        "match_all": {}
      }
    }
    • 模糊查询,name字段的包含Mark的数据
    GET /plan/publishedEop/_search
    {
      "query": {
        "match": { "name" : "Mark!" }
      }
    }

    多字段模糊查询,模糊匹配(bool 查询采取 more-matches-is-better 匹配越多越好的方式;boost 权重)

    GET _search
    {
    "query": {
    "bool":{
    "should":[
    {"match": { "name" : {"query":"Mark!","boost":2} }},
    {"match": { "detail" : "详细!" }}
    ]
    }
    }
    }

    多字段模糊查询(最佳字段,dis_max查询,单个 最佳匹配语句的评分 _score 作为整体评分)

    可以通过指定 tie_breaker 这个参数将其他匹配语句的评分也考虑其中

    GET _search
    {
      "query": {
        "dis_max":{
          "queries":[
            {"match": { "name" : "Mark!" }},
            {"match": { "detail" : "详细!" }}
            ]
        }
      }   
    }
  • 相关阅读:
    vue-实践1
    node 基本使用
    vue通信
    初始AMD和Common.js
    vue正确引入第三方包
    常见的java设计模式
    springboot加ES实现全局检索
    Cookie丢失的原因
    动态SQL
    用Java实现给图片添加文字
  • 原文地址:https://www.cnblogs.com/meng-ma-blogs/p/15494443.html
Copyright © 2011-2022 走看看