const searchParams = {
index: "products", // Replace with your actual Elasticsearch index name
body: {
from: offset,
size: limit,
query: {
bool: {
should: [
{
wildcard: {
name: `*${fullTextSearch}*`,
},
},
{
wildcard: {
code: `*${fullTextSearch}*`,
},
},
],
},
},
},
};
if (category) {
//add and query ( category = category)
}
字符串
如果category!= null,我想将查询类别添加到此searchParams中
如何在elasticsearch查询中添加更多查询?
1条答案
按热度按时间6ju8rftf1#
你可以这样做:
字符串