match all query

donghwikim00·2025년 1월 24일

19_elastic_search

목록 보기
6/11
  • 모든 문서를 검색하기 위해 사용된다.

예제 코드

const axios = require('axios');

const url = 'http://localhost:9200/test_index2/_search';

const query = {
    query: {
        match_all: {}
    }
};

axios.post(url, query)
    .then(res => {
        // console.log(res.data);
        const jsonRes = JSON.stringify(res.data, null, 2);
        console.log(jsonRes)
    })
    .catch(err =>{
        console.error(err);
    }); 
  • 위 코드를 터미널에 아래와 같은 코드가 나온다.
$ node 7.match_all_query.js
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 3,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "test_index2",
        "_id": "M2OylpQB5IgN5vDfFoOH",
        "_score": 1,
        "_source": {
          "name": "Mastering Spring Boot",
          "description": "Spring Boot simplifies the development of Java-based web applications with minimal configuration."
        }
      },
      {
        "_index": "test_index2",
        "_id": "10",
        "_score": 1,
        "_source": {
          "name": "Advanced React React React Patterns",
          "description": "Explore advanced techniques in React to build scalable and maintainable applications."
        }
      },
      {
        "_index": "test_index2",
        "_id": "15",
        "_score": 1,
        "_source": {
          "name": "Advanced React React React Patterns Patterns Patterns",
          "description": "Explore advanced techniques in React to build scalable and maintainable applications."
        }
      }
    ]
  }
}
profile
기술 블로그입니다. 여러 언어에 대한 정리, 프로젝트 설명 등을 기록합니다.

0개의 댓글