예제 코드
const axios = require('axios');
const url = 'http://localhost:9200/test_index2/_search';
const query = {
query: {
match_all: {}
}
};
axios.post(url, query)
.then(res => {
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."
}
}
]
}
}