1

My search results for Electric blanket brings up all products specific to electric/blanket/electric blanket". However, I need results only specific to electric blanket.

The query my application sends to SOLR has :

q="electric" "blanket"

What change is required at SOLR config end to make this search only for electric blanket?

DivB
  • 11
  • 2

3 Answers3

1

In your schema.xml, add to the end of the file, before </schema>:

<solrQueryParser defaultOperator="AND"/>

Solr Documentation: https://wiki.apache.org/solr/SchemaXml#Default_query_parser_operator

alexf
  • 1,303
  • 9
  • 20
  • Thanks alexf. I will be trying the same. So what I am assuming, SOLR will search for "electric" and "blanket". However, won't this create a problem, when I have synonyms for blanket in place. When I have synonyms for blanket my query to SOLR is somewhat like : "electric" "blanket" "throw", so if I use AND, it will search for "electric" and "blanket" and "throw" products which will probably be 0 search results. Is that correct? – DivB Jun 24 '15 at 16:46
  • Hi Alexf, I tried the solution given by you. Changed Schema.xml to use 'AND' instead of 'OR'. However, this has impacted the search results ina negative way. For all searches, I am getting 0 results returned. be it a single term or a multi term, I am getting search results 0 for all. Any suggestions? – DivB Jun 24 '15 at 17:15
  • 1
    For your first comment, this explains that it is better to use synonyms only in index time ! For your second one, try to use the analysis tool of Solr interface to understand why your documents are not matching. – alexf Jun 25 '15 at 07:34
1

in SearchSetup.jspf make the default value of searchType = 1001 instead of 1000

<c:set var="searchType" value="1001" scope="request"/>

below is the explanation - also you can find complete list in same file :

    13.  ANY                    |       1000        |  INCLUDE products, kits, bundles, category level SKUs
                                |     (Default)     |  EXCLUDE product level SKUs
                                |                   |
    14.  EXACT                  |       1001        |  INCLUDE products, kits, bundles, category level SKUs
                                |                   |  EXCLUDE product level SKUs
                                |                   |
    15.  ALL                    |       1002        |  INCLUDE products, kits, bundles, category level SKUs
                                |                   |  EXCLUDE product level SKUs

EXACT will force solr to match the whole sentence , same as when you type your search term in inte qoute "search term" , that will search in products that have EXACT sentence in product name , short description , category name , SEO Keywords , name override and description override

Hope this answer you question.

Thanks Abed

Abed Yaseen
  • 522
  • 4
  • 12
0

You can not have results only specific to just electric blanket. You can however ensure the results specific to electric blanket are more relevant and returned at the top of your results.

The configuration of Solr that Websphere Commerce offers out-of-the-box is very basic. In order to receive desired results takes a lot of tuning and configuration changes in both Solr and Webshere Commerce (We resorted to writing a custom class). sarona.co.uk has some nice information about this in their latest blogs.

everreadyeddy
  • 738
  • 1
  • 8
  • 18