So, first of all, "exact" match is hard in Solr on tokenized fields.
Tokenized fields don't really do that. So for exact match, you should
probably use a non-tokenized field (string or text with keywordtokenizer
(which should really be called the non-tokenizer)). If there's only one
token in your value anyway though, like a single number, it may not
matter and work fine.
Secondly, I'd recommend combining a dismax query for the user-entered
phrase (like 'dog') with standard lucene queries for those other
things. There are (at least) two ways to do that. The first is just put
everything after the first AND in one or more 'fq' parameters instead of
trying to include them in 'q'. The second is to use Solr's nested query
syntax, to specify sub-queries with different query parsers. Someone can
explain the second if you need it, but the easier to understand 'fq'
approach seems right to me for your case.
Swapnonil Mukherjee wrote:
Hi Everybody,
Let me give you a brief idea of our Solr document. We have about 6 text type
fields, each containing IPTC data extracted from photos. Search is performed
mostly on these 6 fields.
We also have a mutlivalue field named group_id that contains a list of all the
group_ids that have access to this photo. In other words we are storing the
metadata of the photo as well as the permissions applicable for this photo in
the Solr document itself. This group_id field by the way is of long type.
Additionally we have certain boolean and constant type fields named
visibleToEndUser (boolean) and entityType (a java enum between 0 to 5).
The first field defaultSearch is a copyField which contains a copy of all the
values of 6 text type fields that I have mentioned.
The way we query presently using the default search handler is like this.
defaultSearch:(Dog) AND (group_id:2181347 OR group_id:2181364 OR
group_id:2216624 OR group_id:2216990) AND (entityType:0) AND
(visibleToEndUser:true)
We want to start using the dismax (if not dismax then edismax) query handler
but so far I have not been able to replicate the query mentioned above to the
equivalent dismax form.
What I cannot figure out is?
1. How do I apply exact match on the group_id, visibleToEndUser and the
entityType fields? Or How how do I query a specific field with a specific value
rather than searching across all fields with all values.
2. How do I apply OR and AND conditions?
Swapnonil Mukherjee