lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael D. Curtin" <m...@curtin.com>
Subject Re: Search precondition: matching area
Date Tue, 16 May 2006 13:14:01 GMT
David Trattnig wrote:

> Hello LuceneList,
> 
> I've got at least following fields in my index:
> 
> AREA = "home news business"
> CONTENTS = "... hello world ..."
> 
> If I submit the query
> 
> query-string: "hello area:home"
> 
> Lucene should only search these documents which has the matching area.
> Actually Lucene searches the area, but it should
> 
>   - NOT return results if the area doesn't match --> actually Lucene
>   searches also in the other fields for the area - indeed with less 
> rating -
>   but they are returned.
>   - NOT include a matching area to the rating
> 
> In other words: The area shouldn't handled like a standard search able
> field, more like a precondition if the query should be applied.

You may need to put a '+' on the query terms that are required, like so:

query-string: "+hello +area:home"

The default operator between query terms, at least for 1.4, is OR.  You can 
change it to AND via QueryParser's setOperator() method, like so:

qp.setOperator(QueryParser.DEFAULT_OPERATOR_AND);

You might also want to check what you set for the default query field in 
QueryParser's constructor, for the "hello" term.

> Additionally: If I submit no area
> 
> query-string: "hello"
> 
> the query should be applied as it would have a matching area.

I'm not sure exactly what you mean.  This simple query will only return 
documents that contain the string "hello" in the default field.  Is that what 
you mean?

--MDC

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


Mime
View raw message