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 Abu Abdulla alhanbali <mo...@gmail.com> on 2007/08/18 08:39:55 UTC

Deleting the result from a query or a filter and not a documents specified by Term

Hi,

Is there a way to delete the results from a query or a filter and not
documents specified by Term. I have seen some explanations here but i do not
know how to do it:

http://www.nabble.com/Batch-deletions-of-Records-from-index-tf615674.html#a1644740

Thanks in advanced

Re: Deleting the result from a query or a filter and not a documents specified by Term

Posted by Abu Abdulla alhanbali <mo...@gmail.com>.
sure.

I have this filter that has this query:

(field1:query1 AND field2:query2) OR (field1:query3 AND field2:query4)

I need to be able to delete the documents that are resulted from this query.
The normal deleting method can delete only this query (field:query) which is
resulted from:
IndexerReader.deleteDocuments(new Term(field, query));

I do not know how to do it.
Appreciate your help,


On 8/18/07, Erick Erickson <er...@gmail.com> wrote:
>
> I don't understand what you mean by that. Could you give a couple
> of examples?
>
> Best
> Erick
>
> On 8/18/07, Abu Abdulla alhanbali <mo...@gmail.com> wrote:
> >
> > Hi,
> >
> > Is there a way to delete the results from a query or a filter and not
> > documents specified by Term. I have seen some explanations here but i do
> > not
> > know how to do it:
> >
> >
> >
> http://www.nabble.com/Batch-deletions-of-Records-from-index-tf615674.html#a1644740
> >
> > Thanks in advanced
> >
>

Re: Deleting the result from a query or a filter and not a documents specified by Term

Posted by Erick Erickson <er...@gmail.com>.
I don't understand what you mean by that. Could you give a couple
of examples?

Best
Erick

On 8/18/07, Abu Abdulla alhanbali <mo...@gmail.com> wrote:
>
> Hi,
>
> Is there a way to delete the results from a query or a filter and not
> documents specified by Term. I have seen some explanations here but i do
> not
> know how to do it:
>
>
> http://www.nabble.com/Batch-deletions-of-Records-from-index-tf615674.html#a1644740
>
> Thanks in advanced
>

Re: Deleting the result from a query or a filter and not a documents specified by Term

Posted by Chris Hostetter <ho...@fucit.org>.
: So iterating over and deleting them term by term wouldn't
: preserve the sense of the original query
: (field1:query1 AND field2:query2) OR (field1:query3 AND field2:query4)

Doh! .. you are 100% correct, i am 100% wrong ... i don't know what i was
thinking when i typed that.

the Filter approach should still work though, and you could alwyas use a
QueryWrapperFilter to make it work for an arbitrary query.




-Hoss


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


Re: Deleting the result from a query or a filter and not a documents specified by Term

Posted by Erick Erickson <er...@gmail.com>.
Chris:

I didn't understand how your first solution would work,
 so I tried it. The terms I extracted from the rewritten
query were just the four raw terms, i.e.

field1:query1
field1:query3
field2:query2
field2:query4.

So iterating over and deleting them term by term wouldn't
preserve the sense of the original query
(field1:query1 AND field2:query2) OR (field1:query3 AND field2:query4)
and would delete (presumably) more documents than just
the documents matching the query.

So what am I missing?

Thanks
Erick



On 8/19/07, Chris Hostetter <ho...@fucit.org> wrote:
>
> : Is there a way to delete the results from a query or a filter and not
> : documents specified by Term. I have seen some explanations here but i do
> not
> : know how to do it:
> :
> :
> http://www.nabble.com/Batch-deletions-of-Records-from-index-tf615674.html#a1644740
>
> the simplest approach that will work in a general case:
>   1) build you query object
>   2) call rewrite on your query
>   3) call extractTerms on the rewritten query
>   4) iterate over all those terms and delete.
>
> if you have Filter it's even easier...
>   1) call the bits method on your filter
>   2) iterate over each bit and call the delete method that takes a docid.
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Deleting the result from a query or a filter and not a documents specified by Term

Posted by Abu Abdulla alhanbali <mo...@gmail.com>.
Greatly appreciated.
It works perfect.

On 8/19/07, Chris Hostetter <ho...@fucit.org> wrote:
>
> : Is there a way to delete the results from a query or a filter and not
> : documents specified by Term. I have seen some explanations here but i do
> not
> : know how to do it:
> :
> :
> http://www.nabble.com/Batch-deletions-of-Records-from-index-tf615674.html#a1644740
>
> the simplest approach that will work in a general case:
>   1) build you query object
>   2) call rewrite on your query
>   3) call extractTerms on the rewritten query
>   4) iterate over all those terms and delete.
>
> if you have Filter it's even easier...
>   1) call the bits method on your filter
>   2) iterate over each bit and call the delete method that takes a docid.
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Deleting the result from a query or a filter and not a documents specified by Term

Posted by Chris Hostetter <ho...@fucit.org>.
: Is there a way to delete the results from a query or a filter and not
: documents specified by Term. I have seen some explanations here but i do not
: know how to do it:
:
: http://www.nabble.com/Batch-deletions-of-Records-from-index-tf615674.html#a1644740

the simplest approach that will work in a general case:
  1) build you query object
  2) call rewrite on your query
  3) call extractTerms on the rewritten query
  4) iterate over all those terms and delete.

if you have Filter it's even easier...
  1) call the bits method on your filter
  2) iterate over each bit and call the delete method that takes a docid.



-Hoss


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