Hi Derek,
It is not clear what you are trying to achieve: "one of the search
fields is an exact phrase match while the rest of the search fields can
be exact or partial matches". What does "while" mean - it has to match
in other fields as well or result should be scored better if it does but
not mandatory to match?
For exact match you can use string type instead of text.
For querying multiple fields you can take a look at (e)dismax query parser.
Regards,
Emir
--
Monitoring * Alerting * Anomaly Detection * Centralized Log Management
Solr & Elasticsearch Support * http://sematext.com/
On 28.01.2016 10:52, Derek Poh wrote:
Hi
First of all, sorry for the long post.
How do I implement or structured the query such that one of the search
fields is an exact phrase match while the rest of the search fields
can be exact or partial matches? Is this possible?
I have the following search fields
- P_VeryShortDescription
- P_ShortDescription
- P_CatConcatKeyword
- spp_keyword_exact
For the spp_keyword_exact field, I want to apply an exact match to it.
I have a document with the following information. If I search for
'dvd', this document should not match. However if I search for 'dvd
bracket', this document should match.
Right now when I search for 'dvd', it is not return, which is correct.
I want it to be return when I search for 'dvd bracket' but it is not.
I try enclosing it in double quotes "dvd bracket" but it is not
return. Then again I can't enclosed the search terms in double quotes
"dvd bracket" as those documents with the word 'dvd' and 'bracket' in
the other fields will not be match, am I right?
doc:
<arrname="spp_keyword_exact">
<str>TV Mounts</str>
<str>dvd bracket</str>
</arr>
<strname="P_VeryShortDescription">TV Mounts</str>
<strname="P_ShortDescription">Swivel TV Mounts, Suitable for 26-42
Inches Screen</str>
<strname="P_CatConcatKeyword">Swivel TV mounts</str>
Here are the fields definition:
<field indexed="true" name="spp_keyword_exact" stored="false"
type="gs_keyword_exact" multiValued="true"/>
<fieldType class="solr.TextField" name="gs_keyword_exact"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishMinimalStemFilterFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishMinimalStemFilterFactory" />
</analyzer>
</fieldType>
The other search fields are defined as
<fieldType name="text_general" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory"
synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.KStemFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory"
synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.KStemFilterFactory"/>
</analyzer>
</fieldType>
Derek
----------------------
CONFIDENTIALITY NOTICE
This e-mail (including any attachments) may contain confidential
and/or privileged information. If you are not the intended recipient
or have received this e-mail in error, please inform the sender
immediately and delete this e-mail (including any attachments) from
your computer, and you must not use, disclose to anyone else or copy
this e-mail (including any attachments), whether in whole or in part.
This e-mail and any reply to it may be monitored for security, legal,
regulatory compliance and/or other appropriate reasons.