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 Miro Max <ki...@yahoo.de> on 2005/02/18 03:58:01 UTC

select where from query type in lucene

Hi,

i've problem with my my classes using lucene.
my index looks like:

type       |   content
-------------------------
document   |  xxxxx
document   |  xxxxx
view       |  xxxxx
view       |  xxxxx
dbentry    |  xxxxx
dbentry    |  xxxxx

my question now:

how can i search for content where type=document or
(type=document OR type=view).
actually i can do it with: "(type:document OR
type:entry) AND queryText" as QueryString.
but does exist any other better way to realize this?

thx

miro


	
		
___________________________________________________________ 
Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de

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


Re: select where from query type in lucene

Posted by Morus Walter <mo...@tanto.de>.
Miles Barr writes:
> On Fri, 2005-02-18 at 03:58 +0100, Miro Max wrote:
> > how can i search for content where type=document or
> > (type=document OR type=view).
> > actually i can do it with: "(type:document OR
> > type:entry) AND queryText" as QueryString.
> > but does exist any other better way to realize this?
>
[...] 
> 
> Another alternative is to put each type in it's own index and use a
> MultiSearcher to pull in the types you want.
> 
If the change rate of the index and the number of commonly used
type combinations aren't too large, cached filters might be another 
alternative.
Of couse the filter would have to be recreated whenever the index changes.
The advantage is, that you save searching for the types for each query
where the filter is reused while you can keep all documents within one 
index.

Morus

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


Re: select where from query type in lucene

Posted by Miles Barr <mi...@runtime-collective.com>.
On Fri, 2005-02-18 at 03:58 +0100, Miro Max wrote:
> how can i search for content where type=document or
> (type=document OR type=view).
> actually i can do it with: "(type:document OR
> type:entry) AND queryText" as QueryString.
> but does exist any other better way to realize this?

What's wrong with that method? I don't think you can do it any simpler. 

Are you concerned about writing a string then having to use the query
parser? You could also build it up manually:

QueryParser parser = ...

Query text = parser.parse(queryText);

Query type = new BooleanQuery();
type.add(new TermQuery(new Term("type", "document")), false, false);
type.add(new TermQuery(new Term("type", "view")), false, false);

Query everything = new BooleanQuery();
everything.add(text, true, false);
everything.add(type, true, false);

That way you could avoid things in queryText overriding the type check.

Another alternative is to put each type in it's own index and use a
MultiSearcher to pull in the types you want.



-- 
Miles Barr <mi...@runtime-collective.com>
Runtime Collective Ltd.


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