lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Filter documents on a field value while searching the index
Date Sat, 22 Jan 2011 20:32:09 GMT
I guess I don't see what the problem is. These look to me like
standard Lucene query syntax options. If I'm off base here,
let me know.

If you're building your own BooleanQuery,
you can add these as sub-clauses

Here's the Lucene query syntax:
http://lucene.apache.org/java/2_9_1/queryparsersyntax.html

See below

Best
Erick

On Sat, Jan 22, 2011 at 2:32 PM, amg qas <amgqas@gmail.com> wrote:

> Hi,
>
> I have couple of questions on filtering result set while performing a
> search in lucene index :
>
> 1) I want to filter the document set returned when searching an index
> based on a match on a particular field.
> For eg if I have a Field in my index called CompanyName - then while
> searching for documents that match
> some query I want to restict the result set to only those documents
> where CompanyName = 'Foo'. I looked
> at the existing Filters in Lucene and could not figure out a way to
> accomplish this using any of those filters.
>
>
Add a clause +CompanyName:foo


> 2) Filter result set on a collection of values - for eg in the case
> mentioned in 1 can I filter documents
> where CompanyName = 'Foo' OR 'Bar' OR 'FooBar'.
>
> Add a clause like +CompanyName:(Foo Bar)


> 3) Filter result set on multiple fields - for eg if my index has the
> fields CompanyName & Location -
> can I filter documents where CompanyName = 'Foo' & Location = 'Arizona'.
>
> +CompanyName:Foo +Location:Arizona


> 4) Filter result set on multiple fileds on collection of values for
> each field - for eg if my index has the fields
> CompanyName & Location - can I filter documents where (CompanyName =
> 'Foo' OR 'Bar') & (Location = 'Arizona'
> OR 'Washington').
>
> +CompanyName:(Foo Bar) +Location:(Arizona Washington)


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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message