Re: Filter question

2023-11-21 Thread Mikhail Khludnev
Hi Trevor
Well, you may negate it via
  qb.add(product_c_positive, Occur.MUST_NOT);
it will work only if there is a sibling MUST/SHOULD clause.
Regarding
qb.add(BooleanQuery.Builder().add(product_c_positive,
Occur.MUST_NOT).build(), Occur.FILTER);
It may hardly work unless Lucene  "adjusts pure negative query" somewhere
that some search servers do or did under certain conditions.

On Wed, Nov 22, 2023 at 7:46 AM Trevor Nicholls 
wrote:

> 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
>
>
>
>

-- 
Sincerely yours
Mikhail Khludnev


Re: Filter question

2006-12-09 Thread Chris Hostetter

: That works fine if there are some criteria in filterQuery and query.
: But sometimes, the bean I'm passing in will not pass any criteria into
: the filterQuery part.  If that's the case, cwf looks like this:
: CachingWrapperFilter(QueryFilter())
...
: will result in no results.  If there are no criteria in the filter,
: shouldn't that return all the results based on the query?

No.  If you filter a query, the filter defines the super set of all
results you can get back -- if you have a filter that matches nothing,
then you can't get anything back.





-Hoss


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]