RE: Building a facet query in SolrJ

2011-08-11 Thread Simon, Richard T
Thanks! I actually found a page on line that explained this.

-Rich

-Original Message-
From: Chris Hostetter [mailto:hossman_luc...@fucit.org] 
Sent: Wednesday, August 10, 2011 4:01 PM
To: solr-user@lucene.apache.org
Cc: Simon, Richard T
Subject: RE: Building a facet query in SolrJ


: query.addFacetQuery(MyField + : + \ + uri + \);
...
: But when I examine queryResponse.getFacetFields, it's an empty list, if 

facet.query constraints+counts do not come back in the facet.field 
section of hte response.  they come back in the facet.query section of 
the response (look at the XML in your browser and you'll see what i 
mean)...

https://lucene.apache.org/solr/api/org/apache/solr/client/solrj/response/QueryResponse.html#getFacetQuery%28%29


-Hoss


Building a facet query in SolrJ

2011-08-10 Thread Simon, Richard T
Hi - I'm trying to do a (I think) simple facet query, but I'm not getting the 
results I expect. I have a field, MyField, and I want to get facets for 
specific values of that field. That is, I want a FacetField if MyField is 
ABC, DEF, etc. (a specific list of values), but not if MyField is any other 
value.

If I build my query like this:

SolrQuery query = new SolrQuery( luceneQueryStr );
  query.setStart( request.getStartIndex() );
  query.setRows( request.getMaxResults() );
  query.setFacet(true);
 query.setFacetMinCount(1);

  query.addFacetField(MYFIELD);

  for (String fieldValue : desiredFieldValues) {
   query.addFacetQuery(MYFIELD + : + fieldValue);
 }


queryResponse.getFacetFields returns facets for ALL values of MyField. I 
figured that was because setting the facet field with addFacetField caused Solr 
to examine all values. But, if I take out that line, then getFacetFields 
returns an empty list.

I'm sure I'm doing something simple wrong, but I'm out of ideas right now.

-Rich






RE: Building a facet query in SolrJ

2011-08-10 Thread Simon, Richard T
Oops. I think I found it. My desiredFieldValues list has the wrong info. Knew 
there was something simple wrong.

From: Simon, Richard T
Sent: Wednesday, August 10, 2011 10:55 AM
To: solr-user@lucene.apache.org
Cc: Simon, Richard T
Subject: Building a facet query in SolrJ

Hi - I'm trying to do a (I think) simple facet query, but I'm not getting the 
results I expect. I have a field, MyField, and I want to get facets for 
specific values of that field. That is, I want a FacetField if MyField is 
ABC, DEF, etc. (a specific list of values), but not if MyField is any other 
value.

If I build my query like this:

SolrQuery query = new SolrQuery( luceneQueryStr );
  query.setStart( request.getStartIndex() );
  query.setRows( request.getMaxResults() );
  query.setFacet(true);
 query.setFacetMinCount(1);

  query.addFacetField(MYFIELD);

  for (String fieldValue : desiredFieldValues) {
   query.addFacetQuery(MYFIELD + : + fieldValue);
 }


queryResponse.getFacetFields returns facets for ALL values of MyField. I 
figured that was because setting the facet field with addFacetField caused Solr 
to examine all values. But, if I take out that line, then getFacetFields 
returns an empty list.

I'm sure I'm doing something simple wrong, but I'm out of ideas right now.

-Rich






RE: Building a facet query in SolrJ

2011-08-10 Thread Simon, Richard T
I take it back. I didn't find it. I corrected my values and the facet queries 
still don't find what I want.

The values I'm looking for are URIs, so they look like: http://place.org/abc/def

I add the facet query like so:

query.addFacetQuery(MyField + : + \ + uri + \);


I print the query, just to see what it is:

Facet Query:  MyField: : http://place.org/abc/def;

But when I examine queryResponse.getFacetFields, it's an empty list, if I do 
not set the facet field. If I set the facet field to MyField, then I get facets 
for ALL the values of MyField, not just the ones in the facet queries.

Can anyone help here?

Thanks.


From: Simon, Richard T
Sent: Wednesday, August 10, 2011 11:07 AM
To: Simon, Richard T; solr-user@lucene.apache.org
Subject: RE: Building a facet query in SolrJ

Oops. I think I found it. My desiredFieldValues list has the wrong info. Knew 
there was something simple wrong.

From: Simon, Richard T
Sent: Wednesday, August 10, 2011 10:55 AM
To: solr-user@lucene.apache.org
Cc: Simon, Richard T
Subject: Building a facet query in SolrJ

Hi - I'm trying to do a (I think) simple facet query, but I'm not getting the 
results I expect. I have a field, MyField, and I want to get facets for 
specific values of that field. That is, I want a FacetField if MyField is 
ABC, DEF, etc. (a specific list of values), but not if MyField is any other 
value.

If I build my query like this:

SolrQuery query = new SolrQuery( luceneQueryStr );
  query.setStart( request.getStartIndex() );
  query.setRows( request.getMaxResults() );
  query.setFacet(true);
 query.setFacetMinCount(1);

  query.addFacetField(MYFIELD);

  for (String fieldValue : desiredFieldValues) {
   query.addFacetQuery(MYFIELD + : + fieldValue);
 }


queryResponse.getFacetFields returns facets for ALL values of MyField. I 
figured that was because setting the facet field with addFacetField caused Solr 
to examine all values. But, if I take out that line, then getFacetFields 
returns an empty list.

I'm sure I'm doing something simple wrong, but I'm out of ideas right now.

-Rich






Re: Building a facet query in SolrJ

2011-08-10 Thread Erik Hatcher
Try making your queries, manually, to see this closer in action... 
q=MyField:uri and see what you get.  In this case, because your URI contains 
characters that make the default query parser unhappy, do this sort of query 
instead:

{!term f=MyField}uri

That way the query is parsed properly into a single term query.

I am a little confused below since you're faceting on MyField entirely 
(addFacetField) where you'd get the values of each URI facet query in that list 
anyway.

Erik

On Aug 10, 2011, at 13:42 , Simon, Richard T wrote:

 I take it back. I didn't find it. I corrected my values and the facet queries 
 still don't find what I want.
 
 The values I'm looking for are URIs, so they look like: 
 http://place.org/abc/def
 
 I add the facet query like so:
 
 query.addFacetQuery(MyField + : + \ + uri + \);
 
 
 I print the query, just to see what it is:
 
 Facet Query:  MyField: : http://place.org/abc/def;
 
 But when I examine queryResponse.getFacetFields, it's an empty list, if I do 
 not set the facet field. If I set the facet field to MyField, then I get 
 facets for ALL the values of MyField, not just the ones in the facet queries.
 
 Can anyone help here?
 
 Thanks.
 
 
 From: Simon, Richard T
 Sent: Wednesday, August 10, 2011 11:07 AM
 To: Simon, Richard T; solr-user@lucene.apache.org
 Subject: RE: Building a facet query in SolrJ
 
 Oops. I think I found it. My desiredFieldValues list has the wrong info. Knew 
 there was something simple wrong.
 
 From: Simon, Richard T
 Sent: Wednesday, August 10, 2011 10:55 AM
 To: solr-user@lucene.apache.org
 Cc: Simon, Richard T
 Subject: Building a facet query in SolrJ
 
 Hi - I'm trying to do a (I think) simple facet query, but I'm not getting the 
 results I expect. I have a field, MyField, and I want to get facets for 
 specific values of that field. That is, I want a FacetField if MyField is 
 ABC, DEF, etc. (a specific list of values), but not if MyField is any 
 other value.
 
 If I build my query like this:
 
 SolrQuery query = new SolrQuery( luceneQueryStr );
  query.setStart( request.getStartIndex() );
  query.setRows( request.getMaxResults() );
  query.setFacet(true);
 query.setFacetMinCount(1);
 
  query.addFacetField(MYFIELD);
 
  for (String fieldValue : desiredFieldValues) {
   query.addFacetQuery(MYFIELD + : + fieldValue);
 }
 
 
 queryResponse.getFacetFields returns facets for ALL values of MyField. I 
 figured that was because setting the facet field with addFacetField caused 
 Solr to examine all values. But, if I take out that line, then getFacetFields 
 returns an empty list.
 
 I'm sure I'm doing something simple wrong, but I'm out of ideas right now.
 
 -Rich
 
 
 
 



RE: Building a facet query in SolrJ

2011-08-10 Thread Simon, Richard T
Hi -- I do get facets for all the values of MyField when I specify the facet 
field, but that's not what I want. I just want facets for a subset of the 
values of MyField. That's why I'm trying to use the facet queries, to just get 
facets for those values.


-Rich

-Original Message-
From: Erik Hatcher [mailto:erik.hatc...@gmail.com] 
Sent: Wednesday, August 10, 2011 2:04 PM
To: solr-user@lucene.apache.org
Subject: Re: Building a facet query in SolrJ

Try making your queries, manually, to see this closer in action... 
q=MyField:uri and see what you get.  In this case, because your URI contains 
characters that make the default query parser unhappy, do this sort of query 
instead:

{!term f=MyField}uri

That way the query is parsed properly into a single term query.

I am a little confused below since you're faceting on MyField entirely 
(addFacetField) where you'd get the values of each URI facet query in that list 
anyway.

Erik

On Aug 10, 2011, at 13:42 , Simon, Richard T wrote:

 I take it back. I didn't find it. I corrected my values and the facet queries 
 still don't find what I want.
 
 The values I'm looking for are URIs, so they look like: 
 http://place.org/abc/def
 
 I add the facet query like so:
 
 query.addFacetQuery(MyField + : + \ + uri + \);
 
 
 I print the query, just to see what it is:
 
 Facet Query:  MyField: : http://place.org/abc/def;
 
 But when I examine queryResponse.getFacetFields, it's an empty list, if I do 
 not set the facet field. If I set the facet field to MyField, then I get 
 facets for ALL the values of MyField, not just the ones in the facet queries.
 
 Can anyone help here?
 
 Thanks.
 
 
 From: Simon, Richard T
 Sent: Wednesday, August 10, 2011 11:07 AM
 To: Simon, Richard T; solr-user@lucene.apache.org
 Subject: RE: Building a facet query in SolrJ
 
 Oops. I think I found it. My desiredFieldValues list has the wrong info. Knew 
 there was something simple wrong.
 
 From: Simon, Richard T
 Sent: Wednesday, August 10, 2011 10:55 AM
 To: solr-user@lucene.apache.org
 Cc: Simon, Richard T
 Subject: Building a facet query in SolrJ
 
 Hi - I'm trying to do a (I think) simple facet query, but I'm not getting the 
 results I expect. I have a field, MyField, and I want to get facets for 
 specific values of that field. That is, I want a FacetField if MyField is 
 ABC, DEF, etc. (a specific list of values), but not if MyField is any 
 other value.
 
 If I build my query like this:
 
 SolrQuery query = new SolrQuery( luceneQueryStr );
  query.setStart( request.getStartIndex() );
  query.setRows( request.getMaxResults() );
  query.setFacet(true);
 query.setFacetMinCount(1);
 
  query.addFacetField(MYFIELD);
 
  for (String fieldValue : desiredFieldValues) {
   query.addFacetQuery(MYFIELD + : + fieldValue);
 }
 
 
 queryResponse.getFacetFields returns facets for ALL values of MyField. I 
 figured that was because setting the facet field with addFacetField caused 
 Solr to examine all values. But, if I take out that line, then getFacetFields 
 returns an empty list.
 
 I'm sure I'm doing something simple wrong, but I'm out of ideas right now.
 
 -Rich
 
 
 
 



RE: Building a facet query in SolrJ

2011-08-10 Thread Chris Hostetter

: query.addFacetQuery(MyField + : + \ + uri + \);
...
: But when I examine queryResponse.getFacetFields, it's an empty list, if 

facet.query constraints+counts do not come back in the facet.field 
section of hte response.  they come back in the facet.query section of 
the response (look at the XML in your browser and you'll see what i 
mean)...

https://lucene.apache.org/solr/api/org/apache/solr/client/solrj/response/QueryResponse.html#getFacetQuery%28%29


-Hoss