You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Mark <st...@gmail.com> on 2013/07/31 19:35:00 UTC

Alternative searches

Can someone explain how one would go about providing alternative searches for a query… similar to Amazon.

For example say I search for "Red Dump Truck"

- 0 results for "Red Dump Truck"
- 500 results for " Red Truck"
- 350 results for "Dump Truck"

Does this require multiple searches? 

Thanks

Re: Alternative searches

Posted by Chris Hostetter <ho...@fucit.org>.
: Can someone explain how one would go about providing alternative searches for a query… similar to Amazon.

: For example say I search for "Red Dump Truck"
: 
: - 0 results for "Red Dump Truck"
: - 500 results for " Red Truck"
: - 350 results for "Dump Truck"

Well -- it depends on what you want to consider as alternative 
suggestions.

1) In your specific example above, it seems like you just want to make 
suggestions bsaed on dropping parts of the input -- there is nothing like 
that in Solr by default, but you could accomplish it by having your solr 
client figure out the possible list of alternatives to consider and then 
asking for the number of matches using "facet.query" -- the trick is to 
make sure you exclude the "q" param from consideration when computing the 
facet counts...

	? q={!tag=main}Red Dump Truck
	& facet=true
	& facet.query={!ex=main}Red Truck
	& facet.query={!ex=main}Dump Truck


2) if what you really want is something like...

   No results for "Red Dump Truck", perhaps you meant...
   - 500 results for "Reed's Dump Truck"
   - 350 results for "Red Dumb Truck"

...then take a look at the spellcheck / suggester feature.

  https://cwiki.apache.org/confluence/display/solr/Spell+Checking

You can regsiter a spellcheck component in your search, and configure it 
to include alternate suggestion collations (with hit counts) in the 
response.

then your client can look at the number of hits from the main search, and 
if it's "0" it can suggest the alternatives based on the spellcheck 
collactions

---

Regardless of wether you really ment #1 or #2 above, the answer to the 
second part of your question is the same...

: Does this require multiple searches? 

...you can get the counts from a single request, but actaully fetching the 
results for one of these alternates would request executing a second solr 
request.



-Hoss

RE: Alternative searches

Posted by "Petersen, Robert" <ro...@mail.rakuten.com>.
Hi Mark

Yes, it is something we implemented also.  We just try various subsets of the search terms when there are zero results.  To increase performance for all these searches we return only the first three results and no facets so we can simply display the result counts for the various subsets of the original search terms.  We only do this if the first search had zero results and then a double metaphone search (which is how we handle misspelled terms) also returned nothing.  We also apply various heuristics to the alternative searches being performed like no one word searches if the original search had many words etc

Thanks
Robi

-----Original Message-----
From: Mark [mailto:static.void.dev@gmail.com] 
Sent: Wednesday, July 31, 2013 10:35 AM
To: solr-user@lucene.apache.org
Subject: Alternative searches

Can someone explain how one would go about providing alternative searches for a query... similar to Amazon.

For example say I search for "Red Dump Truck"

- 0 results for "Red Dump Truck"
- 500 results for " Red Truck"
- 350 results for "Dump Truck"

Does this require multiple searches? 

Thanks