Put parentheses around the original query and your new contraint and
separate them with "AND":
(...) AND (...)
Either of those sub-queries could have any complexity of AND and OR.
Or,
Put the constraint query into a filter query: &fq=... , which will limit the
query results as specified.
-- Jack Krupansky
-----Original Message-----
From: hank williams
Sent: Friday, December 21, 2012 6:45 PM
To: solr-user@lucene.apache.org
Subject: AND OR query
If I do a free text search for a keyword over all my fields using the query
winston churchill
town:*winston churchill* OR label:*winston churchill* OR name:*winston
churchill* OR office:*winston churchill*
I get plenty of results. But If I want to filter the searches down to towns.
So Winston Chruchill was in the town of dundee, how can I keep doing a free
text search over my data but add a mandatory AND?
town:*dundee* OR label:*winston churchill* AND name:*churchill* OR
office:*winston churchill*
In the example above I want say town must be 'dundee' AND name must contain
'churchill'; label and office may or may not contain 'winston churchill',
but from my original free text search I have no idea to know in which field
'winston churchill' oringated from. By knowing that I want to filter down to
town, I can't just say town:*dundee* because this is another query and
'winston churchill' may be a label or may be a name.
Hope this makes sense.
Thanks