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 Shalin Shekhar Mangar <sh...@gmail.com> on 2010/01/04 10:20:07 UTC

Re: Implementing Autocomplete/Query Suggest using Solr

On Wed, Dec 30, 2009 at 3:07 AM, Prasanna R <pl...@gmail.com> wrote:

>  I looked into the Solr/Lucene classes and found the required information.
> Am summarizing the same for the benefit of those that might refer to this
> thread in the future.
>
>  The change I had to make was very simple - make a call to getPrefixQuery
> instead of getWildcardQuery in my custom-modified Solr dismax query parser
> class. However, this will make a fairly significant difference in terms of
> efficiency. The key difference between the lucene WildcardQuery and
> PrefixQuery lies in their respective term enumerators, specifically in the
> term comparators. The termCompare method for PrefixQuery is more
> light-weight than that of WildcardQuery and is essentially an optimization
> given that a prefix query is nothing but a specialized case of Wildcard
> query. Also, this is why the lucene query parser automatically creates a
> PrefixQuery for query terms of the form 'foo*' instead of a WildcardQuery.
>
>
I don't understand this. There is nothing that one should need to do in
Solr's code to make this work. Prefix queries are supported out of the box
in Solr.


> And one final request for Comment to Shalin on this topic - I am guessing
> you ensured there were no duplicate terms in the field(s) used for
> autocompletion. For our first version, I am thinking of eliminating the
> duplicates outside of the results handler that gives suggestions since
> duplicate suggestions originate only from different document IDs in our
> system and we do want the list of document IDs matched. Is there a
> better/different way of doing the same?
>
>
No, I guess not.

-- 
Regards,
Shalin Shekhar Mangar.

Re: Implementing Autocomplete/Query Suggest using Solr

Posted by Prasanna R <pl...@gmail.com>.
On Mon, Jan 4, 2010 at 1:20 AM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, Dec 30, 2009 at 3:07 AM, Prasanna R <pl...@gmail.com> wrote:
>
> >  I looked into the Solr/Lucene classes and found the required
> information.
> > Am summarizing the same for the benefit of those that might refer to this
> > thread in the future.
> >
> >  The change I had to make was very simple - make a call to getPrefixQuery
> > instead of getWildcardQuery in my custom-modified Solr dismax query
> parser
> > class. However, this will make a fairly significant difference in terms
> of
> > efficiency. The key difference between the lucene WildcardQuery and
> > PrefixQuery lies in their respective term enumerators, specifically in
> the
> > term comparators. The termCompare method for PrefixQuery is more
> > light-weight than that of WildcardQuery and is essentially an
> optimization
> > given that a prefix query is nothing but a specialized case of Wildcard
> > query. Also, this is why the lucene query parser automatically creates a
> > PrefixQuery for query terms of the form 'foo*' instead of a
> WildcardQuery.
> >
> >
> I don't understand this. There is nothing that one should need to do in
> Solr's code to make this work. Prefix queries are supported out of the box
> in Solr.
>
>  I  am using the dismax query parser and I match on multiple fields with
different boosts. I run a prefix query on some fields in combination with a
regular field query on other fields. I do not know of any way in which one
could specify a prefix query on a particular field in your dismax query out
of the box in Solr 1.4. I had to update Solr to support additional syntax in
a dismax query that lets you choose to create a prefix query on a particular
field. As part of parsing this custom syntax, I was making a call to the
getWildcardQuery which I simply changed to getPrefixQuery.

Prasanna.