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 Chris Kimm <ch...@seeqa.com> on 2004/02/08 20:07:04 UTC

Matching a single document

This may not fit any of Lucene's usage models, but is there a way to 
match a single document - before it has been indexed - to a query?

The motivation for this is to add a listener to the IndexWriter which 
listens for documents matching existing Query objects.  Two possible 
approaches, both of which seem ungainly, are 1) creating a temporary 
index for each document being indexed or 2) Writing a class that matches 
document Fields with Query Terms.  This second approach would require a 
way to extract individual Terms from Queries.  Is that possible?

Thanks,

Chris




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


Re: Matching a single document

Posted by Daniel Naber <da...@t-online.de>.
On Sunday 08 February 2004 20:07, Chris Kimm wrote:

>  Two possible
> approaches, both of which seem ungainly, are 1) creating a temporary
> index for each document being indexed 

You can use a RAMDirectory for indexing so nothing needs to be written to 
disk. This should be quite fast.

> or 2) Writing a class that matches 
> document Fields with Query Terms.  This second approach would require a
> way to extract individual Terms from Queries.  Is that possible?

Yes, you need to recursively iterate over all parts of the query. For 
example, a boolean query may consist of other boolean queries. You need to 
go down until you've got a TermQuery, which holds the term itself (or you 
could use rewrite() to make this easier).

Regards
 Daniel

-- 
http://www.danielnaber.de

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