I'm trying to order facets from a single query with multiple facet queries.
But facet.order and facet.mincount are not working.
the query is:
facet.query=text:word1&facet.query=text:word2&facet.query=text:word3&facet=true&q=*:*&facet.mincount=50&facet.sort=count
I'm generating it with solrj
query.setQuery("*:*");
query.setFacet(true);
query.setFacetSort(FacetParams.FACET_SORT_COUNT); //count
query.setFacetMinCount(50);
query.addFacetQuery("text:word1");
query.addFacetQuery("text:word2");
query.addFacetQuery("text:word3");
the response is:
...facet_counts={facet_queries={text:word1=597,text:word2=23,text:word3:1100},facet_fields={},facet_dates={},facet_ranges={}}}
Thanks.
UPDATE
It seems that facet.field must be set to use the other facet.mincount and facet.sort. But it only affects to the words in facet field not the facet queries. Is that true? Any solution?
Yes, either you do a "query faceting" (without extra parameters) or a "field faceting" that has all the parameters (mincount, order, etc)
http://wiki.apache.org/solr/SimpleFacetParameters#facet
BTW, ampersand is missing after q=*:* in:
facet.query=text:word1&facet.query=text:word2&facet.query=text:word3&facet=true&q=*:*facet.mincount=50&facet.sort=count
Related
I'm using Solr 8.11.2. In order to boost documents with certain field values, I'm using Dismax's bq (Boost Query) parameter.
From what I've read, this should only influence the score of the search results returned by the rest of the query. What I see happening is that it filters all search results that don't have the field I'm boosting.
I'm using the following query, which returns all documents containing both words procedure and maintenance:
q=((+procedure+maintenance))&rows=10&start=0&wt=xml&q.op=AND&fl=id,score,alias,author,hash,collection,label,url,lastModified,path,extension,objectId,objectDtType,title,DocumentPK_s,Taal_s,Site_s,SharePointId_s&hl=true&hl.qt=highlightRH&hl.fl=content,description,label&hl.snippets=5&defType=dismax&bf=recip(max(0,ms(NOW-3MONTH,creationDate)),3.16e-11,1,1)&pf=content&sort=score DESC
But as soon as I append &bq=language:english^10000, which is supposed to boost documents where the field language is set to english, all documents where the field language doesn't exist are no longer part of the results.
Am I misunderstanding how this parameter is supposed to work? Is it a side effect?
Is there any way to get facet.query results only for the main query, without a facet.filter query.
For example, I have the request:
q=item_id:*
&fq=item_param:3
&facet.query=item_param:1
&facet.query=item_param:2
Is it possible to get facets from all item results (item_id:*), not from fq (item_param:3)?
This can be done by tagging and excluding filters. First, you want to tag your filter queries with a tag (e.g., filters):
fq={!tag=filters}item_param:3
Second, tell your facet queries to ignore the tag you used for the filters:
facet.query={!ex=filters}item_param:1
facet.query={!ex=filters}item_param:2
Someone please give me a decent explanation of the difference between q and fq in Solr query, covering some points such as -
Do they have the same syntax?
Do they return same results?
When to use which one and why?
Any other differences
Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter.
The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).
The q parameter takes your query and execute against the index. Then you can use filter queries (can use multiple filter queries) to filter the results.
For example your query can look like this.
q=author:shakespeare
this will match the documents which has 'shakespeare' in the 'author' field. Then you can use filter queries like this.
fq=title:hamlet
fq=type:play
Those will filter the results based on the other fields. You can even filter on the same field.
The query syntax is similar for both q and fq parameters
I have a solr server setup and am attempting to get facets working correctly, the following query
/select?q=*:*&wt=xml&indent=true?&facet=true&facet.field=style&facet.field=variety&facet.field=packsize&fq=packsize:6&fq=CABERNET
Where there are three facet fields "style, variety and packsize". The query above returns a number of correct results however when I execute this
/select?q=*:*&wt=xml&indent=true?&facet=true&facet.field=style&facet.field=variety&facet.field=packsize&fq=packsize:6&fq=variety:CABERNET
Suddenly I receive zero results why does prefixing "variety" to the fq break for this but not for packsize?
Also when trying to add &fq=style:red or &fq=red neither of these work even though there are many results with "style = red". Any ideas??
For the filter queries if the field is not specified, the query would work on the default field.
You can check the filter query executed by adding debugQuery=on
<arr name="parsed_filter_queries">
<str>text:solr100</str>
</arr>
So check for the default field should have the CABERNET term.
Also the match would depend upon the field type, the analysis performed and where the field is indexed or not.
Only fields indexed would be able to filter the results.
Is it possible to boost fields that appear in filter queries (fq=) in Solr?
I have a faceted query that has a tagged filter query something like this:
...&q=*:*&fq={!tag:X}brand:(+"4911")+OR+body:(abc)&facet.field={!ex:X}brand&..
(I facet on brand and the facet is set to ignore the filter query tagged X, so I need to use a filter query.)
I would like to make matches on the brand field score higher than matches on body field in the filter query.
The fields brand and body are multivalued.
I've tried adding bf=/bq= arguments, and I can get brand matches to score higher if I change the filter query to be the main 'q=' query, but I don't seem to be able to influence the score of anything in the filter query. I think I maybe going about it in the wrong way..
Thanks.
Solr "fq"'s do not affect score -- see the wiki. So, you should add your queries to "q" that you actually want to boost. If need be, you can always duplicate a query restriction in both "q" and "fq", as "fq" only acts as a restriction on the results set.