Hi Ugo,

You can use facet.prefix on a tokenized field instead of a String field.

Example:
<field name="product" type="string" … />
<field name="product_tokens" type="text_split" … /><!-- use e.g. 
WhitespaceTokenizer or WordDelimiter and others, see example schema.xml that 
comes with SOLR -->

facet.prefix on "product" will only return hits that match the start of the 
single token stored in that field.
As "product_tokens" contains the value of "product" tokenized in a fashion that 
suites you, it can contain multiple tokens. facet.prefix on "product_tokens" 
will return hits that match *any* of these tokens - which is what you want.

Chantal

Am 25.07.2012 um 15:29 schrieb Ugo Matrangolo:

> Hi,
> 
> I'm working on making our autocomplete engine a bit more smart.
> 
> The actual impl is a basic facet based autocompletion as described in the
> 'SOLR 3 Enterprise Search' book: we use all the typed tokens except the
> last one to build a facet.prefix query on an autocomplete facet field we
> built at index time.
> 
> This allows us to have something like:
> 
> 'espress' --> '*espress*o machine', '*espress*o maker', etc
> 
> We want something like:
> 
> 'espress' -> '*espress*o machine', '*espress*o maker', 'kMix *espress*o
> maker'
> 
> Note that the last suggested term could be not obtained by quering on the
> facet prefix as we do now. What we need is a way to find the 'espress'
> string in the middle of the name/description of our products.
> 
> Any suggestions ?
> 
> Cheers,
> Ugo

Reply via email to