satyarajp
(SatyaRaj)
December 18, 2017, 5:13am
1
Hi Team,
Can you please help me if the below code(es v0.9) can be replaced
BoolFilterBuilder filter = FilterBuilders.boolFilter().filterName("compositeFilter");
filterBuilder.must(FilterBuilders.termsFilter("keyword", toLowerCase(filterList)));
by the following (es v6)
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.filter(QueryBuilders.termsQuery("keyword", toLowerCase(filterList))).must();
dadoonet
(David Pilato)
December 18, 2017, 6:17am
2
That might be ok.
You can remove must()
at the end BTW.
satyarajp
(SatyaRaj)
December 18, 2017, 6:29am
3
Ohh.. Then how do I differentiate/specify must, mustnot while using boolquery as filter ?
dadoonet
(David Pilato)
December 18, 2017, 7:35am
4
You can add a bool
within a bool.filter
clause.
satyarajp
(SatyaRaj)
December 18, 2017, 8:27am
5
Hi Sir,
I'm missing something here. I don't completely understand.
query.filter(QueryBuilders.termsQuery("keyword", toLowerCase(filterList)));
The above snippet is what could be proper replacement.
I'm not getting how do we specify exact must
clauses. Can you help me with similar code line.
Thank you,
Regards,
SatyaRaj
dadoonet
(David Pilato)
December 18, 2017, 10:27am
6
Why do you want to use must
when you can use filter
?
satyarajp
(SatyaRaj)
December 18, 2017, 10:37am
7
OK, So v6 is basically moving out of this must filter and then mustnot ?
My usecase is to usemustNot
in some cases
dadoonet
(David Pilato)
December 18, 2017, 10:56am
8
yes.
Your original example was without must_not
. But you can basically use filter
to filter (no scoring), must_not
to remove documents from the resultset, and must
or should
if relevancy matters.
satyarajp
(SatyaRaj)
December 18, 2017, 11:43am
9
satyarajp:
must
That helps. David..Will Use this way now. will keep you posted in case of any further issues.
system
(system)
Closed
January 15, 2018, 11:43am
10
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.