We're using Solr as a backend for an ECommerce site/system. The Solr
index stores products with selected attributes, as well as a dedicated
field for autocomplete suggestions (Done via AJAX request when typing in
the search box without pressing return).

The autosuggest field is supplied by copyField directives from certain
select product attribute fields (description and/or name mostly). It
uses EdgeNGramFilterFactory to complete words not yet typed completely,
and it works quite well.

However, we come across an issue with a disconnect between the
autosuggest results and results of a "normal search", that is, a query
over the full fields of the product. Let's say there are products that
are called "motor".

- When autosuggesting, typing "mot" autosuggests all products with
"motor", because the EdgeNGram created "m", "mo", "mot", "moto" and
"motor", respectively, and it matches.
- When searching for "mot", however (i.e. pressing enter when seeing the
autosuggestions), it doesn't find any products. The autosuggest field is
not part of the "real" search, and no product attribute contains "mot"
as a word.

One obvious solution would be to incorporate the "autosuggest" field
into the "real" search, however, this adds many tokens to the index that
aren't really part of the products indexed and makes for strange search
results, for example when an NGram is also a word, but the record itself
does contain the search term only as part of a word.

Are there clever solutions to this problem? 

Reply via email to