Hi
I'm constructing a BooleanQuery with an optional filter query and a
mandatory content query, plus some optional boost queries.
In effect, what I am doing is implementing this shorthand:
BooleanQuery.Builder qb = new BooleanQuery.Builder();
if (filter) {
qb.add(filterquery, Occur.FILTER);
}
qb.add(contentquery, Occur.MUST);
if (boost)
qb.add(boostquery, Occur.SHOULD);
..
}
Query fullquery = qb.build();
Typically the content query will be constructed from something like
"title:word OR text:word" and the filter query, if it exists, will be built
from something like "product:a". (The boost queries serve to push recent
content higher in the results, they don't really matter for this question.)
There will always be a content query. My question relates to the filter
query. I know that a query which has no 'positive' clauses will not return
any results. That although the two queries
product:a or product:b or product:d
and
NOT product:c
might be logically identical, the first will return results and the second
will not.
However would a query like "NOT product:c" be OK as a filter query if it was
combined with other queries as per the pseudocode above?
I don't think it's significant but for what it's worth this application is
still using Lucene 8_6.3.
cheers
T
I'm constructing a BooleanQuery with an optional filter query and a
mandatory content query, plus some optional boost queries.
In effect, what I am doing is implementing this shorthand:
BooleanQuery.Builder qb = new BooleanQuery.Builder();
if (filter) {
qb.add(filterquery, Occur.FILTER);
}
qb.add(contentquery, Occur.MUST);
if (boost)
qb.add(boostquery, Occur.SHOULD);
..
}
Query fullquery = qb.build();
Typically the content query will be constructed from something like
"title:word OR text:word" and the filter query, if it exists, will be built
from something like "product:a". (The boost queries serve to push recent
content higher in the results, they don't really matter for this question.)
There will always be a content query. My question relates to the filter
query. I know that a query which has no 'positive' clauses will not return
any results. That although the two queries
product:a or product:b or product:d
and
NOT product:c
might be logically identical, the first will return results and the second
will not.
However would a query like "NOT product:c" be OK as a filter query if it was
combined with other queries as per the pseudocode above?
I don't think it's significant but for what it's worth this application is
still using Lucene 8_6.3.
cheers
T