lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul <p...@waite.net.nz>
Subject Re: Mixing database and lucene searches
Date Tue, 11 May 2004 05:07:06 GMT
Matt Quail wrote:

> "And" join: if you want to do a query like "select rows where
> name='matt' and text contains 'foo'", then the psuedo code is:

> Hits hits = searcher.search(new TermQuery("text", "foo")
> Set hitPKs = new Set();
> for each doc in hits:
>    hitPKs.put(doc.getField("pk"))
>
> rsPKs = new Set();
> ResultSet rs = sql.execute("select PK from TABLE where name='matt'")
> for each row in rs:
>    rsPKs.put(rs.get("pk"));
> Set results = intersection(rsPKs, hitPKs);


But presumably if you make sure that the field "name" is indexed in
Lucene (not necessarily stored), it's far quicker to do a two-stage process,
where you search Lucene for "text:foo AND name:matt" and then just fill-in
any other metadata with a fast little DB lookup for the small returned set of
primary keys?

Cheers,
Paul.

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


Mime
View raw message