其他分享
首页 > 其他分享> > ES常见查询语句

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