I'm using Solr 4.3. I have built range facet for field price, for which I gave a f.price.facet.range.start, a f.price.facet.range.end and f.price.facet.range.gap, but I cant figure out how to compute the facet for values inferior or superior to a certain value.
Maybe I dont know the exact syntax : f.price.facet.range.other.before=1000000.
According to the documentation on on Facet Range Other, this will only work for values that fall within the range being computed. So for your example, if 1000000 is not within your current range start/end values, you will not get a result from the range.other.before parameter. However, you can still get the facet for this price, by including it as a separate facet.query request.
For your example, you would include te following parameter:
facet.query=price:[* TO 1000000]
Related
I have a Solr 6.2 instance running, and I'm exploring its advantages and limitations. One limitation I've run into seems to be that you can't sort or filter the data based off of a field function query.
.../solr/collection/select?q=*:*&fl=*,total:sum(v1,v2)&fq=total:[10 TO *]
Solr responds with an error stating that the total field does not exist. Indeed, the field is not defined in my schema because it's not a stored part of the dataset - it's calculated at query time. They call it a pseudo field. I haven't been able to find an example in the documentation or a solution online. So, is there a way around this?
.../solr/collection/select?q=*:*&fl=*,total:sum(v1,v2)&fq={!frange l=10} sum(v1,v2)
I have very same problem as you.
I want to query particular division value of two fields.
I tried to used [0.3 TO *] like you.
You can also use upper bound for your range if you need.
http://archive.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-4.6.pdf
"l" is for lower bound.
"u" is for upper bound.
fq={!frange l=0 u=2.2} sum(user_ranking,editor_ranking)
Maybe this works for you?
you can do this. instead of total try sum.
you can find more info here. https://wiki.apache.org/solr/FunctionQuery#What_is_a_Function.3F
an example from the sole wiki.
Example Function Queries
To give you a better understanding of how function queries can be used in Solr, suppose an index stores the dimensions in meters x,y,z of some hypothetical boxes with arbitrary names stored in field boxname. Suppose we want to search for box matching name findbox but ranked according to volumes of boxes. The query parameters would be:
q=boxname:findbox val:"product(x,y,z)"
This query will rank the results based on volumes. In order to get the computed volume, you will need to request the score, which will contain the resultant volume:
&fl=*, score
Suppose that you also have a field storing the weight of the box as weight. To sort by the density of the box and return the value of the density in score, you would submit the following query:
http://localhost:8983/solr/collection_name/select?q=boxname:findbox val:"div(weight,product(x,y,z))"&fl=boxname x y z weight score`
you can read more about it here. https://cwiki.apache.org/confluence/display/solr/Function+Queries
Try this
solr/collection/select?q=*:* _val_:"sum(v1,v2)"&fl=* score&fq={!frange l=10 }sum(v1,v2)
I have got this query in solr. The problem is, i am getting search results that contains a category of items named "PRD DELETED".
Now all the items that have "PRD DELETED", i want to display those at the end.
For Ex if 100 records are there and one page contains 25 records, then on the last page "PRD DELETED" records should display.
Pls note that "PRD DELETED" is a value and not any category. I think down boosting is needed here, but i am unable to find the exact solution.
Any suggestion here would be a big help.
The solution is usually to do the opposite: boost all documents that isn't deleted, instead of trying to negatively boost those that is. Boosts are either multiplicative or additive, and while multiplicative boosts can reduce the score value, the additive can't. bq and qf are additive, while boost is multiplicative.
The Relevancy FAQ has an example for this case:
When using (e)dismax, people sometimes expect that specifying a pure negative query with a large boost in the "bq" param will work (since Solr automatically makes top level purely negative positive queries by adding an implicit ":" -- but this doesn't work with "bq", because of how queries specified via "bq" are added directly to the main query. You need to be explicit...
?defType=dismax
&q=foo bar
&bq=(*:* -xxx)^999
Implementing it as a multiplicative boost would probably involve using if and then returning either 1 or a lower value depending on whether the field has the given value.
I'm creating a uneven range facet and I want to support multiple selection for it. However, facet on the tags/exclusions for filters stop working.
Following is my price facet ranges
0-20
20-50
50-100
100-*
Initially I am populating above range with using facet query.
Now whenever end user are selecting 0-20 and 20-50,
I am generating the following
http://localhost:8983/solr/catalog/select?q=games&facet=true&wt=xml&rows=0& fq={!tag=salePrice}salePrice:[0 TO 20]&facet.query={!ex=salePrice}[0 to 20]& fq={!ex=salePrice}salePrice:[20 TO 50]&facet.query={!ex=salePrice}[20 to 50]& other params.
& system is returning zero results.
I am seeing following SOLR JIRA bug closed as fixed.
https://issues.apache.org/jira/browse/SOLR-3819
However, in case,only one facet.query is in action.
In my example, i am using multiple facet.query with uneven ranges.
Please help.
Your query has two fq clauses that don't overlap. That is why you get zero results — nothing to do with the facets or tags themselves. For multi selection you need to combine them with an "OR".
Instead of
...&fq={!tag=salePrice}salePrice:[0 TO 20]&...&fq={!ex=salePrice}salePrice:[20 TO 50]&...
you want
...&fq={!tag=salePrice}salePrice:[0 TO 20] OR salePrice:[20 TO 50]&...
(or combine into a single range)
Some weird behavior with solr range query:
When my primary_longitude range's lower limit is less than -100, then solr does not return any result, eventhough the data is present.
http://localhost:8983/solr/<CORE>/select/?qt=dismax&q=Y&qf=show_all_flag&fl=*&fq=primary_longitude%3A%5B-97.500+TO+-101.999%5D&rows=25&start=0&sort=available_y+desc%2C+net_score+desc&wt=json&debugQuery=true
The query below should return a subset of data that is returned by the above query, so i know there is data that matches the query.
WORKS:
http://localhost:8983/solr/<CORE>/select/?qt=dismax&q=Y&qf=show_all_flag&fl=*&fq=primary_longitude%3A%5B-97.500+TO+-99.999%5D&rows=25&start=0&sort=available_y+desc%2C+net_score+desc&wt=json&debugQuery=true
Any ideas? I tried reversing the order of the numbers in query 1 and that returned results that were not in that range.
Few things you can check for :-
The primary_longitude field is defined as tdouble with proper precision for treating it as a number and not as a text values. (Need to see your schema.xml)
The Negative numbers should probably be reversed from lower to higher [-101.999 TO -97.500]
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.