Solr group.facet=true will not return facet counts - solr

As the title states, I can't get facet values or counts to return when using the group.facet=true parameter. group.truncate appears to return the correct values, but that's not what I'm looking for.
I started with the Solr 4 alpha, then Beta, and I'm now working on the nightly build from 9/5/2012.
I'm grouping by a single value field. The fields I am faceting on are a mix of single and multi value fields. I've simplified my query here MyFacetField represents a single value field.
Here are the grouping parameters:
group.field=GroupField
group.ngroups=true
group.facet=true
group=true
Facet set up like this:
f.MyFacetField.facet.limit=-1
f.MyFacetField.facet.mincount=1
f.MyFacetField.facet.sort=false
facet.field=MyFacetField
facet=true
Match all documents:
q:*:*
Again, my problems is:
When I specify group.facet=true I get the list of facet fields I specified in the request paramaters with no values and no counts.
WHen I specify group.facet=false (or leave the parameter out) I get facet values and counts for the ungrouped result set as expected.
According to the wiki this feature is included in solr4.

It turns out that the issue was in this parameter.
f.MyFacetField.facet.limit=-1
When limit is set to -1 (all) and group.facet=true, facet values and their respective counts are not returned by solr. I'm not sure if this is intended behavior, or not. This doesn't appear to be a requirement of truncate or of faceting in general with group.facet=false.

Related

Facet for Empty or null values for any field in Solr

I am using Facet in my solr implemententation. Facets are display for all the keywords of fields having concrete values.
Facets are not displayed for the empty values. I want to show a facets for empty values as well.
For example, in below example data facet is displayed for the value in Country field as
Sample Data for Solr fields
US (6)
CA (5)
IND (5)
I also want to show facet as
[Empty] (7)
Please suggest some workaround to get Facet for empty values.
You can use facet.missing to get a count for the number of documents that doesn't have a value in the field.
The facet.missing Parameter
If set to true, this parameter indicates that, in addition to the Term-based constraints of a facet field, a count of all results that match the query but which have no facet value for the field should be computed and returned in the response.
The default value is false.
This parameter can be specified on a per-field basis with the syntax of f.<fieldname>.facet.missing.

SOLR Faceting not returning all facets when searching for "All" (*:*)

I've noticed something curious with our SOLR 7 results.
We have faceting enabled on, for example, a manufacturer field.
When a search is performed for a particular manufacturer, the facet data will include a number of results for that manufacturer (in this case, 99 results). Also, all the facet results add up to match the total number of documents matching the query (which makes sense).
If a "blank" search is performed (resulting in a : query), all documents are returned from SOLR (~242,000). The facet results for the manufacturer field are no longer adding up to the total number of documents returned, however. It ends up being ~36,000 documents short. The specific manufacturer that I searched for in the prior example, which DID return a count of 99 in the facet data for that manufacturer, now returns nothing for that manufacturer. There is no facet result shown for that manufacturer.
If I query solr for the specific manufacturer value in the specific field we're faceting on, then it finds the 99 matches, and the facet data also shows the 99 results.
I think this problem is only happening when a : (or blank q) query is done.
Any suggestions?
Please let me know if you require more information.
Thanks,
Bill
I'm not sure I get your problem true but I suggest you some typical solution.
you can use "enum" facet method for huge facets.
facet.method=enum
Furthermore you need to control facet counts with:
facet.limit=10000 //maximum number of returned facets
facet.offset= 0
for more information about Solr facet params go to:
https://wiki.apache.org/solr/SimpleFacetParameters

stats.field and stats.facet doesn't seem to be working right

I'm storing a series of records that contain a section_url and a count fields.
I'm trying to aggregate by section_url and sum the count field, so I'm querying with the following params:
"params":{
"indent":"true",
"stats.field":"count",
"stats":"true",
"q":"section_url:tv AND domain:[* TO *] AND date:\"2014-12-22T00:00:00Z\"",
"stats.facet":"section_url",
"wt":"json"}}
As you can see, I'm running stats on the count field and stats faceting on section_url.
Most of the times this is working fine, but for some reason it's being buggy for some fields. For example, this result My result
As you can see, all the section_url's are http://www.cb10.tv/ . However, for some reason my stats faceting seems to think section_url is actually two fields, www.cb10 and tv instead of http://www.cb10.tv/
Any idea of what could be the problem?
Seems like section_url is tokenized as you get several tokens for each entry. Faceting is performed on the indexed token, which means that you end up with a count for each token in the indexed content - and not for the content of the field itself.
Add a StrField (or a TextField with a KeywordTokenizer) and do a copyField to populate it (or change the existing field), and reindex your content. Use that field for generating the facet counts instead.

Solr facet counts for specific field values

Solr creates multi-select facet counts for me as described here:
https://web.archive.org/web/20131202095639/http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams
I also have various predefined searches that allow a user to browse the catalog. Here is one such example and its query parameters:
q=*:*
fq={!tag=g}genre:western
facet=on
facet.field={!ex=g}genre
facet.mincount=1
facet.limit=50
With this search I get up to 50 genre values in the facet list. I then go through and mark which values were selected by the user; western in this case. This works well except when western is pushed out of the top 50. So I manually add it to the list to make a total of 51. This way the user can see that it is indeed selected. The problem is I have to leave the count for western blank because I don't know it.
Is there a way to get counts for specific facet values such as western in this case? Or another approach to solve this issue?
I am using Solr 4.7.0.
Solr allows you to create a query-based facet count by using the facet.query parameter. When creating a filter query (fq) that's based on a facet field value, I now create a corresponding facet query:
facet.query={!ex=g}genre:western
and add it to the rest of my parameters:
q=*:*
fq={!tag=g}genre:western
facet=on
facet.field={!ex=g}genre
facet.query={!ex=g}genre:western
facet.mincount=1
facet.limit=50
The facet_queries object will now be populated in the solr response:
{
...
"facet_counts": {
"facet_queries": {
"{!ex=g}genre:western": 7
},
...
},
...
}
Regardless of what is returned in the facet_fields object, I'm now guaranteed to have a facet count for genre:western. With some parsing, facet field counts can be extracted from the facet queries.

finding duplicate field values in solr

Using Solr 4.3
I have a field "digest" in a solr index - and I would like to execute a query that will return me all the cases where there are duplicate values of digest. Can this be done?
For the records that have duplicate values, I would like to return other values - such as "url" which may not be duplicated.
You have two options, neither perfect.
You can use Grouping/Field Collapsing which will group by digest and can give you other fields, but does not allow you to avoid groups with only 1 element.
Or you can use Facets, which allow you to specify minimum number of elements for that facet value, but do not allow you to see which documents match that facet. Though you might be able to get something useful by using Pivot (nested) facets.

Resources