ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ES常见查询语句

2022-01-18 20:03:12  阅读:181  来源: 互联网

标签:语句 index search cargo GET slowlog 查询 type ES


GET /_template/cargo_template

GET cargo_index-202110/_search
{
  "query": {
    "match_all": {}
  }
}

GET cargo_index-202111/_search
{
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "createTime": {
        "order": "desc"
      }
    }
  ],
  "from": 0,
  "size": 100
}

GET _template 
GET cargo_index-202111/_search
{
  "query": {
    "match": {
      "cargoId": 29951002600481

    }
  }
}

GET /cargo_index-202110/_segments

GET cargo_index-202201/_settings

GET cargo_index-202110

GET cargo_index-202110/_search
{
  "query": {
    "match": {
      "cargoStatus": 2
    }
  }
}

HEAD cargo_index-202110

GET cargo_index-202110/_search
{
  "query": {
    "match": {
      "splendidSharedCar": 1
    }
  }
}

GET cargo_index-202110/_search
{
  "query": {
    "match": {
      "dispatchStatus": 2
    }
  }
}

PUT /_template/cargo_template
{
  "index_patterns": "cargo_index-*",
  "order": 1,
  "settings": {
    "refresh_interval": "1s",
    "number_of_shards": "10",
    "number_of_replicas": "1",
    "index.indexing.slowlog.threshold.index.warn": "50ms",
    "index.indexing.slowlog.threshold.index.info": "-1",
    "index.indexing.slowlog.threshold.index.debug": "-1",
    "index.indexing.slowlog.threshold.index.trace": "-1",
    "index.indexing.slowlog.level": "warn",
    "index.indexing.slowlog.source": "true",
    "index.search.slowlog.threshold.query.warn": "50ms",
    "index.search.slowlog.threshold.query.info": "-1",
    "index.search.slowlog.threshold.query.debug": "-1",
    "index.search.slowlog.threshold.query.trace": "-1",
    "index.search.slowlog.threshold.fetch.warn": "50ms",
    "index.search.slowlog.threshold.fetch.info": "-1",
    "index.search.slowlog.threshold.fetch.debug": "-1",
    "index.search.slowlog.threshold.fetch.trace": "-1",
    "index.search.slowlog.level": "warn"
  },
  "mappings": {
    "properties": {
      "cargoId": {
        "type": "long"
      },
      "endLoadTime": {
        "type": "long"
      },
      "cargoResource": {
        "type": "keyword"
      },
      "cargoCheck": {
        "type": "keyword"
      },
      "cargoStatus": {
        "type": "keyword"
      },
      "dispatchStatus": {
        "type": "keyword"
      },
      "loadProvince": {
        "type": "keyword"
      },
      "loadCity": {
        "type": "keyword"
      },
      "loadDistrict": {
        "type": "keyword"
      },
      "unloadProvince": {
        "type": "keyword"
      },
      "unloadCity": {
        "type": "keyword"
      },
      "unloadDistrict": {
        "type": "keyword"
      },
      "weightBefore": {
        "type": "integer"
      },
      "weightAfter": {
        "type": "integer"
      },
      "capacityBefore": {
        "type": "integer"
      },
      "capacityAfter": {
        "type": "integer"
      },
      "splendidSharedCar": {
        "type": "keyword"
      },
      "freight": {
        "type": "integer"
      },
      "plusFee": {
        "type": "integer"
      },
      "deposit": {
        "type": "integer"
      },
      "totalFreight": {
        "type": "integer"
      },
      "depositCanRefund": {
        "type": "keyword"
      },
      "createTime": {
        "type": "long"
      },
      "remark": {
        "type": "text"
      },
      "packageTypeCode": {
        "type": "text"
      },
      "packageTypeText": {
        "type": "text"
      },
      "betweenDistance": {
        "type": "integer"
      },
      "updateTime": {
        "type": "long"
      }
    }
  }
}

GET /_template/cargo_template


GET cargo_index-202110/_mapping
{
  "query": {
    "match_all": {}
  }
}

GET cargo_index-202110

GET cargo_index-*/_search
{
  "from": 0,
  "size": 10,
  "timeout": "1m",
  "query": {
    "bool": {
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "cargoId",
      "endLoadTime",
      "cargoResource",
      "cargoCheck",
      "cargoStatus",
      "dispatchStatus",
      "loadProvince",
      "loadCity",
      "loadDistrict",
      "unloadProvince",
      "unloadCity",
      "unloadDistrict",
      "weightBefore",
      "weightAfter",
      "capacityBefore",
      "capacityAfter",
      "splendidSharedCar",
      "freight",
      "deposit",
      "depositCanRefund",
      "totalFreight",
      "createTime",
      "remark",
      "packageTypeCode",
      "packageTypeText",
      "betweenDistance"
    ],
    "excludes": []
  },
  "sort": [
    {
      "splendidSharedCar": {
        "order": "desc"
      }
    },
    {
      "createTime": {
        "order": "asc"
      }
    }
  ]
}


GET cargo_index-202110/_search
{
  "query": {
    "wildcard": {
      "remark": {
        "value": "*"
      }
    }
  }
}

GET /cargo_index-202110/_search?pretty
{
  "query": {
    "bool": {
      "must": [
        {"term": {
          "cargoId": {
            "value": 10141155359512
          }
        }},
        {"term": {
          "dispatchStatus": {
            "value": 1
          }
        }},{"range": {
          "endLoadTime": {
            "gte": 20,
            "lte": 1634659200000
          }
        }}
      ]
    }
  }
}

GET /cargo_index-202110/_search?pretty
{
  "query": {
    "bool": {
      "must": [
        
        {"term": {
          "dispatchStatus": {
            "value": 1
          }
        }},{"range": {
          "endLoadTime": {
            "gte": 20,
            "lte": 1634659200000
          }
        }}
      ]
    }
  }
}

 

标签:语句,index,search,cargo,GET,slowlog,查询,type,ES
来源: https://www.cnblogs.com/juniorMa/p/15819539.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有