On Mon, Jan 4, 2010 at 1:20 AM, Shalin Shekhar Mangar < shalinman...@gmail.com> wrote:
> On Wed, Dec 30, 2009 at 3:07 AM, Prasanna R <plistma...@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.