You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Selva Kumar <se...@gmail.com> on 2015/06/27 02:38:22 UTC

Lucene 5: Query and Filter merger

With Query/Filter merger, it appears default Filter hashcode() varies by
class, not object instance. Different object instances could have same
value. Am I missing something?

Re: Lucene 5: Query and Filter merger

Posted by Adrien Grand <jp...@gmail.com>.
On Sun, Jun 28, 2015 at 1:30 AM, Selva Kumar
<se...@gmail.com> wrote:
> it appears 4.x Filter and our custom implementation inherited Object's
> hashcode and equals method. Obviously, this worked for us so far. Logical
> equality might not be important in this case and likely to be expensive
> given the nature of the custom filters.
>
> Just wanted to understand any changes are around the corner before I
> override these methods in the custom filters.
>
> It seems in some sense Filter has already become a Query. So what does it
> mean to rewrite filter using Query API?
> Search would call take only query instead of combination of query and
> filter?

Our long-term goal is to remove org.apache.lucene.Filter entirely.
Rewriting a Filter using the Query API means that instead of extending
Filter and implementing getDocIdSet, you would have to extend Query
and implement createWeight or rewrite(IndexReader). Then this query
would be used as a FILTER clause in a BooleanQuery instead of a Filter
in a FilteredQuery.

-- 
Adrien

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Lucene 5: Query and Filter merger

Posted by Selva Kumar <se...@gmail.com>.
Hi Adrien

it appears 4.x Filter and our custom implementation inherited Object's
hashcode and equals method. Obviously, this worked for us so far. Logical
equality might not be important in this case and likely to be expensive
given the nature of the custom filters.

Just wanted to understand any changes are around the corner before I
override these methods in the custom filters.

It seems in some sense Filter has already become a Query. So what does it
mean to rewrite filter using Query API?
Search would call take only query instead of combination of query and
filter?

Thanks a lot.
-Selva


On Sat, Jun 27, 2015 at 5:33 PM, Adrien Grand <jp...@gmail.com> wrote:

> Hi Selva,
>
> Indeed, this default implementation is not good enough for most
> filters and should be extended in order to include parameters that
> define the "identity" of the filter. One could argue that using object
> identity might be a better default, but since Filter now extends Query
> it also needs to implement clone() in such a way that a clone of a
> filter is equal to the original filter, which would never work when
> using object identity by default for equals.
>
> If you have custom filters, I would encourage you to rewrite them
> using the query API instead of Filter.
>
>
> On Sat, Jun 27, 2015 at 2:38 AM, Selva Kumar
> <se...@gmail.com> wrote:
> > With Query/Filter merger, it appears default Filter hashcode() varies by
> > class, not object instance. Different object instances could have same
> > value. Am I missing something?
>
>
>
> --
> Adrien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Lucene 5: Query and Filter merger

Posted by Adrien Grand <jp...@gmail.com>.
Hi Selva,

Indeed, this default implementation is not good enough for most
filters and should be extended in order to include parameters that
define the "identity" of the filter. One could argue that using object
identity might be a better default, but since Filter now extends Query
it also needs to implement clone() in such a way that a clone of a
filter is equal to the original filter, which would never work when
using object identity by default for equals.

If you have custom filters, I would encourage you to rewrite them
using the query API instead of Filter.


On Sat, Jun 27, 2015 at 2:38 AM, Selva Kumar
<se...@gmail.com> wrote:
> With Query/Filter merger, it appears default Filter hashcode() varies by
> class, not object instance. Different object instances could have same
> value. Am I missing something?



-- 
Adrien

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org