Query DSL

RainbowMagic發表於2024-03-06

match_all

匹配所有文件,預設分頁查詢,只顯示後十條資料,如下所示在索引中的資料有11條資料,在進行match_all查詢時只返回了十條資料.

    "total": {
      "value": 11,
      "relation": "eq"
    }
GET /es_db/_search
{
  "query": {
    "match_all": {
    }
  }
}

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 11,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "es_db",
        "_id": "10",
        "_score": 1,
        "_source": {
          "name": "開人員",
          "sex": 1,
          "age": 32,
          "address": "武漢東湖高新區未來智匯城",
          "remark": "golang developer"
        }
      },
      {
        "_index": "es_db",
        "_id": "8",
        "_score": 1,
        "_source": {
          "name": "張星",
          "sex": 1,
          "age": 32,
          "address": "武漢東湖高新區未來智匯城",
          "remark": "golang developer"
        }
      },
      {
        "_index": "es_db",
        "_id": "6",
        "_score": 1,
        "_source": {
          "name": "趙虎",
          "sex": 1,
          "age": 32,
          "address": "長沙麓谷興工國際產業園",
          "remark": "java architect"
        }
      },
      {
        "_index": "es_db",
        "_id": "5",
        "_score": 1,
        "_source": {
          "name": "張龍",
          "sex": 0,
          "age": 19,
          "address": "長沙麓谷企業廣場",
          "remark": "java architect assistant"
        }
      },
      {
        "_index": "es_db",
        "_id": "7",
        "_score": 1,
        "_source": {
          "name": "李虎",
          "sex": 1,
          "age": 32,
          "address": "廣州番禺節能科技園",
          "remark": "java architect"
        }
      },
      {
        "_index": "es_db",
        "_id": "3",
        "_score": 1,
        "_source": {
          "name": "王五",
          "sex": 0,
          "age": 26,
          "address": "廣州白雲山公園",
          "remark": "php developer"
        }
      },
      {
        "_index": "es_db",
        "_id": "1",
        "_score": 1,
        "_source": {
          "name": "張三",
          "sex": 1,
          "age": 25,
          "address": "廣州天河公園",
          "remark": "java developer"
        }
      },
      {
        "_index": "es_db",
        "_id": "2",
        "_score": 1,
        "_source": {
          "name": "李四",
          "sex": 1,
          "age": 28,
          "address": "廣州荔灣大廈",
          "remark": "java assistant"
        }
      },
      {
        "_index": "es_db",
        "_id": "4",
        "_score": 1,
        "_source": {
          "name": "趙六",
          "sex": 0,
          "age": 22,
          "address": "長沙橘子洲",
          "remark": "python assistant"
        }
      },
      {
        "_index": "es_db",
        "_id": "11",
        "_score": 1,
        "_source": {
          "name": "企業人員",
          "sex": 1,
          "age": 32,
          "address": "武漢東湖高新區未來智匯城",
          "remark": "golang developer"
        }
      }
    ]
  }
}

相關文章