Re: Do you believe in Clause sanity?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Do you believe in Clause sanity?

Andy Lee-2
Oops, I'm confusing libraries.  I meant I want to remove a Nutch  
Clause from a Nutch Query.

--Andy

On Oct 13, 2005, at 4:45 PM, Andy Lee wrote:

> The API for BooleanQuery only seems to allow adding clauses.  The  
> nearest way I can see to *remove* a clause is by laboriously  
> constructing a new BooleanQuery (assuming you aren't absolutely  
> tied to the original instance) and adding all the clauses from the  
> original query except the one you're removing.  And *that's* rather  
> cumbersome because you can't actually add a clause; you have to use  
> one of the addRequired-/addProhibited- methods -- and they take  
> arrays of String rather than the array of Term that you can get  
> from a Clause.
>
> It seems reasonable to me to want to remove clauses from a query.  
> Is there some reasonable way of doing this that I'm missing?
>
> --Andy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Do you believe in Clause sanity?

Andy Lee-2
On Oct 13, 2005, at 5:21 PM, Andy Lee wrote:
>> It seems reasonable to me to want to remove clauses from a query.  
>> Is there some reasonable way of doing this that I'm missing?

Not to become a one-person thread or anything (and I'll shut up if  
this attempt gets no answers), but this seems like a straightforward  
question.  Is there some design principle I'm missing that would be  
violated if clauses could be removed from a query?

Here's a couple of examples where I think this would be desirable:

* If one has a visual query editor that lets the user construct a  
list of clauses, it seems reasonable to let the user delete a clause  
from a list.  Sure, you could reconstruct a new Query instance, but  
MVC design would more naturally suggest that you have a query object  
that gets modified in place.

* Say you want to show results of variations on a query as well as  
the original query.  The most straightforward way would be to modify  
the clauses.

--Andy

Reply | Threaded
Open this post in threaded view
|

Re: Do you believe in Clause sanity?

Doug Cutting-2
Andy Lee wrote:
> Not to become a one-person thread or anything (and I'll shut up if  this
> attempt gets no answers), but this seems like a straightforward  
> question.  Is there some design principle I'm missing that would be  
> violated if clauses could be removed from a query?

No, not that I can think of.  The public constructors for Query are
limited in order to prohibit certain things that are not yet supported,
like optional and nested clauses.

Doug
Reply | Threaded
Open this post in threaded view
|

Re: Do you believe in Clause sanity?

Andy Lee-2
On Oct 17, 2005, at 1:44 PM, Doug Cutting wrote:
> Andy Lee wrote:
>> [...] Is there some design principle I'm missing that would be  
>> violated if clauses could be removed from a query?
>>
>
> No, not that I can think of.  The public constructors for Query are  
> limited in order to prohibit certain things that are not yet  
> supported, like optional and nested clauses.

Thanks, Doug.  In that case, please consider this a request for a  
couple of API changes which you may be planning anyway:

  * addClause() and removeClause() methods in Query.
  * Setters in Query.Clause for its term/phrase.

In the meantime, I've got my workaround, which is to create a new  
query from the old one, excluding the clauses I want to delete (which  
is more laborious than it could be, since I have to figure out which  
of Query's addXXX() methods to use for each clause).  Fortunately I'm  
not absolutely bound to the original Query instance.

Thanks again,
--Andy

Reply | Threaded
Open this post in threaded view
|

Re: Do you believe in Clause sanity?

Doug Cutting-2
Andy Lee wrote:
> Thanks, Doug.  In that case, please consider this a request for a  
> couple of API changes which you may be planning anyway:
>
>  * addClause() and removeClause() methods in Query.
>  * Setters in Query.Clause for its term/phrase.

Please submit a bug report, ideally with a patch file attached.

Doug
Reply | Threaded
Open this post in threaded view
|

Re: Do you believe in Clause sanity?

Andy Lee-2
On Oct 17, 2005, at 2:50 PM, Doug Cutting wrote:
> Please submit a bug report, ideally with a patch file attached.

Okay, I just filed a bug ticket for myself here at work to remind me  
to submit a change request and patch to you when I get a chance. :)

--Andy