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 dabboo <ag...@sapient.com> on 2009/03/31 08:00:23 UTC
Issue in Range Search Query
Hi,
I am searching for all the records in the index where author's last name
starts with a or b. I am giving my query like
au_last_name:[a* TO b*]
But it is returning all the other records where last name starts with E, P
or other letter.
Please suggest how I can achieve this. I dont want to hit solr 2 times.
Because in future it could be the case, if I have to search for a to z.
Also, is there any way I can get individual count of records starting with
one particular alphabet.
Thanks,
Amit Garg
--
View this message in context: http://www.nabble.com/Issue-in-Range-Search-Query-tp22798861p22798861.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Issue in Range Search Query
Posted by Erick Erickson <er...@gmail.com>.
Would [a TO bzzzzzzz] work?
On Tue, Mar 31, 2009 at 10:46 AM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:
> On Tue, Mar 31, 2009 at 11:30 AM, dabboo <ag...@sapient.com> wrote:
>
> >
> > Hi,
> >
> > I am searching for all the records in the index where author's last name
> > starts with a or b. I am giving my query like
> >
> > au_last_name:[a* TO b*]
> >
> > But it is returning all the other records where last name starts with E,
> P
> > or other letter.
> >
> > Please suggest how I can achieve this. I dont want to hit solr 2 times.
> > Because in future it could be the case, if I have to search for a to z.
>
>
> That is not a valid range query. The best way to do this is to index the
> first character in a separate field in the index.
>
> Alternatively, you can search for fq=au_last_name:a* OR au_last_name:b* and
> so on. However, try to avoid prefix queries because they are more
> expensive.
>
>
> >
> > Also, is there any way I can get individual count of records starting
> with
> > one particular alphabet.
>
>
> Yes, you can use facet=true&facet.field=au_last_name&facet.prefix=a to get
> the number of records in which au_last_name begins with a. As I noted
> earlier, it is better to index the first character separately and facet on
> that.
>
> --
> Regards,
> Shalin Shekhar Mangar.
>
Re: Issue in Range Search Query
Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Tue, Mar 31, 2009 at 11:30 AM, dabboo <ag...@sapient.com> wrote:
>
> Hi,
>
> I am searching for all the records in the index where author's last name
> starts with a or b. I am giving my query like
>
> au_last_name:[a* TO b*]
>
> But it is returning all the other records where last name starts with E, P
> or other letter.
>
> Please suggest how I can achieve this. I dont want to hit solr 2 times.
> Because in future it could be the case, if I have to search for a to z.
That is not a valid range query. The best way to do this is to index the
first character in a separate field in the index.
Alternatively, you can search for fq=au_last_name:a* OR au_last_name:b* and
so on. However, try to avoid prefix queries because they are more expensive.
>
> Also, is there any way I can get individual count of records starting with
> one particular alphabet.
Yes, you can use facet=true&facet.field=au_last_name&facet.prefix=a to get
the number of records in which au_last_name begins with a. As I noted
earlier, it is better to index the first character separately and facet on
that.
--
Regards,
Shalin Shekhar Mangar.