const axios = require("axios");
const url = "http://localhost:9200/test_index/_search";
const query = {
query: {
bool: {
// must: [
// // AND 조건
// {
// match: {
// name: "D",
// },
// },
// ],
// must_not: [
// // NOT 조건
// {
// match: {
// name: "A",
// },
// },
// ],
should: [
// OR 조건
{
// match: {
// name: "B",
// },
// match: {
// price: 300,
// },
range: { price: { gte: 200, lte: 400 } },
},
],
},
},
};
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);
});
must: name이 D가 들어간 모든 걸 조회
should: price가 200보다 크거나 또는 400보다 작은 데이터
must_not: name에 A가 들어가지 않은 모든 데이터를 조회한다.