Search using Query DSL
curl -XPOST 'http://localhost:9200/product/items/_search?pretty=true' -d '{
"query" : {
"filtered" : {
"query" : {
"query_string" : {
"query" : "원피스",
"default_field" : "itemName"
}
},
"filter" : {
"and" : [{
"not" : {
"term" : {
"itemId" : "1000"
}
}
}]
}
}
}
}
QueryStringQueryBuilder Example
QueryStringQueryBuilder builder = new QueryStringQueryBuilder(itemName);
builder.defaultField("itemName");
builder.defaultOperator(QueryStringQueryBuilder.Operator.OR);
AndFilterBuilder andFilterBuilder = FilterBuilders.andFilter();
andFilterBuilder.add(FilterBuilders.notFilter(FilterBuilders.termFilter("itemId", itemId)));
FilteredQueryBuilder filteredQueryBuilder = new FilteredQueryBuilder(builder, andFilterBuilder);
SearchQuery query = new NativeSearchQueryBuilder().withQuery(filteredQueryBuilder).build();
댓글
댓글 쓰기