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 Chris Hostetter <ho...@fucit.org> on 2013/08/15 02:57:54 UTC
Re: 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"
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