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 chandan khatri <ch...@gmail.com> on 2016/04/03 08:11:21 UTC

How to implement Autosuggestion

Hi All,

I've a query regarding autosuggestion. My use case is as below:

1. User enters product name (say Nokia)
2. I want suggestions along with the category with which the product
belongs. (e.g Nokia belongs to "electronics" and "mobile" category) so I
want suggestion like Nokia in electronics and Nokia in mobile.

I am able to get the suggestions using the OOTB AnalyzingInFixSuggester but
not sure how I can get the category along with the suggestion(can this
category be considered as facet of the suggestion??)

Any help/pointer is highly appreciated.

Thanks,
Chandan

Re: How to implement Autosuggestion

Posted by chandan khatri <ch...@gmail.com>.
Hi Alessandro,

Thanks for replying!

Here are my answers inline.

1. "First of all, simple string autosuggestion or document autosuggestion ?
(
with more additional field to show then the label)


---- Document autosuggestions
2. Are you interested in the analysis for the text to suggest ? Fuzzy
suggestions ? exact "beginning of the phrase" suggestions ? infix
suggestions ?"

--- I am interested in analysis for the text to suggest.

3. In the case you want to show the label AND the category AND whatever ( in
Amazon style to make it simple) .
A very straighforward solution is to model a specific Solr Field for your
product collection.
This field will contain the name of the product, analyzed according your
need.
Then your autosuggester will simply hit that field on each char typed, and
you can show the entire document in the suggestions ( with all the fields
you want) .

---- Not sure what you mean by indexing a field with the name of product
analyzed according to my need? Can you please give an example?

Thanks again for taking time to respond to my query.

On Thu, Apr 7, 2016 at 12:59 AM, chandan khatri <ch...@gmail.com>
wrote:

> Hi Alessandro,
>
> Thanks for replying!
>
> Here are my answers inline.
>
>
>
>
> On Mon, Apr 4, 2016 at 6:34 PM, Alessandro Benedetti <
> abenedetti@apache.org> wrote:
>
>> Hi Chandan,
>> I will answer as my previous answer to a similar topic that got lost :
>> "First of all, simple string autosuggestion or document autosuggestion ? (
>> with more additional field to show then the label)
>> Are you interested in the analysis for the text to suggest ? Fuzzy
>> suggestions ? exact "beginning of the phrase" suggestions ? infix
>> suggestions ?"
>>
>> If you need only the category *payloadField* should be what you need .
>> I never used it as a feature but it is there [1] .
>> As Reth suggested, at the moment Solr supports only one payloadField,
>> ignoring the others ( code confirms this).
>>
>> In the case you want to show the label AND the category AND whatever ( in
>> Amazon style to make it simple) .
>> A very straighforward solution is to model a specific Solr Field for your
>> product collection.
>> This field will contain the name of the product, analyzed according your
>> need.
>> Then your autosuggester will simply hit that field on each char typed, and
>> you can show the entire document in the suggestions ( with all the fields
>> you want) .
>> Or we take a look to the implementation and we contribute the support for
>> multiple *payloadField*.
>>
>> Cheers
>>
>> [1] https://cwiki.apache.org/confluence/display/solr/Suggester
>>
>> On Sun, Apr 3, 2016 at 1:09 PM, Reth RM <re...@gmail.com> wrote:
>>
>> > There is a payload attribute but I'm not sure if this can be used for
>> such
>> > use case. Lets wait for others contributors to confirm.
>> > Similar question posted here:
>> >
>> >
>> http://stackoverflow.com/questions/32434186/solr-suggestion-with-multiple-payloads
>> > .
>> >
>> > If its just a category that you need then the work around(although not
>> > accurate one) that I can think of is to include the category value to
>> the
>> > same field with pipe separation and extract from it?
>> >
>> > On Sun, Apr 3, 2016 at 11:41 AM, chandan khatri <
>> chandankhatri1@gmail.com>
>> > wrote:
>> >
>> > > Hi All,
>> > >
>> > > I've a query regarding autosuggestion. My use case is as below:
>> > >
>> > > 1. User enters product name (say Nokia)
>> > > 2. I want suggestions along with the category with which the product
>> > > belongs. (e.g Nokia belongs to "electronics" and "mobile" category)
>> so I
>> > > want suggestion like Nokia in electronics and Nokia in mobile.
>> > >
>> > > I am able to get the suggestions using the OOTB
>> AnalyzingInFixSuggester
>> > but
>> > > not sure how I can get the category along with the suggestion(can this
>> > > category be considered as facet of the suggestion??)
>> > >
>> > > Any help/pointer is highly appreciated.
>> > >
>> > > Thanks,
>> > > Chandan
>> > >
>> >
>>
>>
>>
>> --
>> --------------------------
>>
>> Benedetti Alessandro
>> Visiting card : http://about.me/alessandro_benedetti
>>
>> "Tyger, tyger burning bright
>> In the forests of the night,
>> What immortal hand or eye
>> Could frame thy fearful symmetry?"
>>
>> William Blake - Songs of Experience -1794 England
>>
>
>

Re: How to implement Autosuggestion

Posted by chandan khatri <ch...@gmail.com>.
Hi Alessandro,

Thanks for replying!

Here are my answers inline.




On Mon, Apr 4, 2016 at 6:34 PM, Alessandro Benedetti <ab...@apache.org>
wrote:

> Hi Chandan,
> I will answer as my previous answer to a similar topic that got lost :
> "First of all, simple string autosuggestion or document autosuggestion ? (
> with more additional field to show then the label)
> Are you interested in the analysis for the text to suggest ? Fuzzy
> suggestions ? exact "beginning of the phrase" suggestions ? infix
> suggestions ?"
>
> If you need only the category *payloadField* should be what you need .
> I never used it as a feature but it is there [1] .
> As Reth suggested, at the moment Solr supports only one payloadField,
> ignoring the others ( code confirms this).
>
> In the case you want to show the label AND the category AND whatever ( in
> Amazon style to make it simple) .
> A very straighforward solution is to model a specific Solr Field for your
> product collection.
> This field will contain the name of the product, analyzed according your
> need.
> Then your autosuggester will simply hit that field on each char typed, and
> you can show the entire document in the suggestions ( with all the fields
> you want) .
> Or we take a look to the implementation and we contribute the support for
> multiple *payloadField*.
>
> Cheers
>
> [1] https://cwiki.apache.org/confluence/display/solr/Suggester
>
> On Sun, Apr 3, 2016 at 1:09 PM, Reth RM <re...@gmail.com> wrote:
>
> > There is a payload attribute but I'm not sure if this can be used for
> such
> > use case. Lets wait for others contributors to confirm.
> > Similar question posted here:
> >
> >
> http://stackoverflow.com/questions/32434186/solr-suggestion-with-multiple-payloads
> > .
> >
> > If its just a category that you need then the work around(although not
> > accurate one) that I can think of is to include the category value to the
> > same field with pipe separation and extract from it?
> >
> > On Sun, Apr 3, 2016 at 11:41 AM, chandan khatri <
> chandankhatri1@gmail.com>
> > wrote:
> >
> > > Hi All,
> > >
> > > I've a query regarding autosuggestion. My use case is as below:
> > >
> > > 1. User enters product name (say Nokia)
> > > 2. I want suggestions along with the category with which the product
> > > belongs. (e.g Nokia belongs to "electronics" and "mobile" category) so
> I
> > > want suggestion like Nokia in electronics and Nokia in mobile.
> > >
> > > I am able to get the suggestions using the OOTB AnalyzingInFixSuggester
> > but
> > > not sure how I can get the category along with the suggestion(can this
> > > category be considered as facet of the suggestion??)
> > >
> > > Any help/pointer is highly appreciated.
> > >
> > > Thanks,
> > > Chandan
> > >
> >
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
>
> William Blake - Songs of Experience -1794 England
>

Re: How to implement Autosuggestion

Posted by Alessandro Benedetti <ab...@apache.org>.
Hi Chandan,
I will answer as my previous answer to a similar topic that got lost :
"First of all, simple string autosuggestion or document autosuggestion ? (
with more additional field to show then the label)
Are you interested in the analysis for the text to suggest ? Fuzzy
suggestions ? exact "beginning of the phrase" suggestions ? infix
suggestions ?"

If you need only the category *payloadField* should be what you need .
I never used it as a feature but it is there [1] .
As Reth suggested, at the moment Solr supports only one payloadField,
ignoring the others ( code confirms this).

In the case you want to show the label AND the category AND whatever ( in
Amazon style to make it simple) .
A very straighforward solution is to model a specific Solr Field for your
product collection.
This field will contain the name of the product, analyzed according your
need.
Then your autosuggester will simply hit that field on each char typed, and
you can show the entire document in the suggestions ( with all the fields
you want) .
Or we take a look to the implementation and we contribute the support for
multiple *payloadField*.

Cheers

[1] https://cwiki.apache.org/confluence/display/solr/Suggester

On Sun, Apr 3, 2016 at 1:09 PM, Reth RM <re...@gmail.com> wrote:

> There is a payload attribute but I'm not sure if this can be used for such
> use case. Lets wait for others contributors to confirm.
> Similar question posted here:
>
> http://stackoverflow.com/questions/32434186/solr-suggestion-with-multiple-payloads
> .
>
> If its just a category that you need then the work around(although not
> accurate one) that I can think of is to include the category value to the
> same field with pipe separation and extract from it?
>
> On Sun, Apr 3, 2016 at 11:41 AM, chandan khatri <ch...@gmail.com>
> wrote:
>
> > Hi All,
> >
> > I've a query regarding autosuggestion. My use case is as below:
> >
> > 1. User enters product name (say Nokia)
> > 2. I want suggestions along with the category with which the product
> > belongs. (e.g Nokia belongs to "electronics" and "mobile" category) so I
> > want suggestion like Nokia in electronics and Nokia in mobile.
> >
> > I am able to get the suggestions using the OOTB AnalyzingInFixSuggester
> but
> > not sure how I can get the category along with the suggestion(can this
> > category be considered as facet of the suggestion??)
> >
> > Any help/pointer is highly appreciated.
> >
> > Thanks,
> > Chandan
> >
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Re: How to implement Autosuggestion

Posted by Reth RM <re...@gmail.com>.
There is a payload attribute but I'm not sure if this can be used for such
use case. Lets wait for others contributors to confirm.
Similar question posted here:
http://stackoverflow.com/questions/32434186/solr-suggestion-with-multiple-payloads
.

If its just a category that you need then the work around(although not
accurate one) that I can think of is to include the category value to the
same field with pipe separation and extract from it?

On Sun, Apr 3, 2016 at 11:41 AM, chandan khatri <ch...@gmail.com>
wrote:

> Hi All,
>
> I've a query regarding autosuggestion. My use case is as below:
>
> 1. User enters product name (say Nokia)
> 2. I want suggestions along with the category with which the product
> belongs. (e.g Nokia belongs to "electronics" and "mobile" category) so I
> want suggestion like Nokia in electronics and Nokia in mobile.
>
> I am able to get the suggestions using the OOTB AnalyzingInFixSuggester but
> not sure how I can get the category along with the suggestion(can this
> category be considered as facet of the suggestion??)
>
> Any help/pointer is highly appreciated.
>
> Thanks,
> Chandan
>