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 Aakash Dharmadhikari <aa...@gmail.com> on 2009/09/09 11:12:54 UTC

Creating facet query using SolrJ

hello,

  I am using SolrJ to access solr indexes. When constructing query, I create
a lucene query and use query.toString to create SolrQuery.

  I am facing difficulty while creating facet query for individual field, as
I could not find an easy and clean way of constructing facet query with
parameters specified at field level.

  As I understand, the faceting parameters like limit, sort order etc. can
be set on SolrQuery object but they are used for all the facets in query. I
would like to provide these parameters separately for each field. I am
currently building such query in Java code using string append. But it looks
really bad, and would be prone to breaking when query syntax changes in
future.

  If there any better way of constructing such detailed facet queries, the
way we build the main solr search query?

regards,
aakash

Re: Creating facet query using SolrJ

Posted by Aakash Dharmadhikari <aa...@gmail.com>.
thanks avlesh,

  solrQuery.set("f.myField.facet.limit",10) ...

this is how I ended up doing it, and it works perfectly for me. It just
didn't look good in all neat Solr API calls :), as my complete query
construction logic i

regards,
aakash

2009/9/9 Avlesh Singh <av...@gmail.com>

> >
> > When constructing query, I create a lucene query and use query.toString
> to
> > create SolrQuery.
> >
> Go this thread -
>
> http://www.lucidimagination.com/search/document/f4d91628ced293bf/lucene_query_to_solr_query
>
> I am facing difficulty while creating facet query for individual field, as
> I
> > could not find an easy and clean way of constructing facet query with
> > parameters specified at field level.
> >
> Per field overrides for facet params using SolrJ is not supported yet.
> However, you can always use
> solrQuery.set("f.myField.facet.limit",10) ...
> to pass field specific facet params to the SolrServer.
>
> Cheers
> Avlesh
>
> On Wed, Sep 9, 2009 at 2:42 PM, Aakash Dharmadhikari <aakashd@gmail.com
> >wrote:
>
> > hello,
> >
> >  I am using SolrJ to access solr indexes. When constructing query, I
> create
> > a lucene query and use query.toString to create SolrQuery.
> >
> >  I am facing difficulty while creating facet query for individual field,
> as
> > I could not find an easy and clean way of constructing facet query with
> > parameters specified at field level.
> >
> >  As I understand, the faceting parameters like limit, sort order etc. can
> > be set on SolrQuery object but they are used for all the facets in query.
> I
> > would like to provide these parameters separately for each field. I am
> > currently building such query in Java code using string append. But it
> > looks
> > really bad, and would be prone to breaking when query syntax changes in
> > future.
> >
> >  If there any better way of constructing such detailed facet queries, the
> > way we build the main solr search query?
> >
> > regards,
> > aakash
> >
>

Re: Creating facet query using SolrJ

Posted by Avlesh Singh <av...@gmail.com>.
>
> When constructing query, I create a lucene query and use query.toString to
> create SolrQuery.
>
Go this thread -
http://www.lucidimagination.com/search/document/f4d91628ced293bf/lucene_query_to_solr_query

I am facing difficulty while creating facet query for individual field, as I
> could not find an easy and clean way of constructing facet query with
> parameters specified at field level.
>
Per field overrides for facet params using SolrJ is not supported yet.
However, you can always use
solrQuery.set("f.myField.facet.limit",10) ...
to pass field specific facet params to the SolrServer.

Cheers
Avlesh

On Wed, Sep 9, 2009 at 2:42 PM, Aakash Dharmadhikari <aa...@gmail.com>wrote:

> hello,
>
>  I am using SolrJ to access solr indexes. When constructing query, I create
> a lucene query and use query.toString to create SolrQuery.
>
>  I am facing difficulty while creating facet query for individual field, as
> I could not find an easy and clean way of constructing facet query with
> parameters specified at field level.
>
>  As I understand, the faceting parameters like limit, sort order etc. can
> be set on SolrQuery object but they are used for all the facets in query. I
> would like to provide these parameters separately for each field. I am
> currently building such query in Java code using string append. But it
> looks
> really bad, and would be prone to breaking when query syntax changes in
> future.
>
>  If there any better way of constructing such detailed facet queries, the
> way we build the main solr search query?
>
> regards,
> aakash
>