Solr 4.1 range filter query does not work in a specific scenario - solr

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]

Related

In Solr, how to get all the unique values from a field? there are more than 100 values?

Below query gives be the unique values of that field. But it returns only top 100. Not sure how to get all the unique values.
"'http://localhost:8983/solr/select/?q=%3A&rows=0&facet=on&facet.field=txt'"
PS: My field is a tokenized field. Not sure if that makes any difference.
You can use facet.limit to change the number of returned values. Set it to -1 to make Solr return all possible values for a field and not just the top 100.
&facet=on&facet.field=txt&facet.limit=-1
You can also use f.txt.facet.limit=-1 if you have more than one facet and just want to change the value for that single field.
You can also use the Terms component to retrieve the tokens indexed for a specific field - depending on your use case it might be more efficient to use the terms component instead - you'll have to evaluate the performance for your exact use case and setup.

Solr Query for Range of UUID

I'm trying to write a query that returns all the documents within a range of UUIDs. I expect there to be 3 docs in the result, but there are may more. It seems like my range query is not working.
Here is my range query:
&fq=id:"25e12906-ee0d-45d5-b53c-de4b3f4e54de" TO "ac416be1-4d2e-45f9-bcb8-39b514a2659d"
When I do not include this filter, 25e12906-ee0d-45d5-b53c-de4b3f4e54de is the first item returned, and ac416be1-4d2e-45f9-bcb8-39b514a2659d is the 3rd. Thats why I am expecting 3 in my result. My result however has much more (44 items).
Is what I am doing possible?
if you want a range query, you need to use the proper syntax:
fq=id:[25e12906-ee0d-45d5-b53c-de4b3f4e54de TO ac416be1-4d2e-45f9-bcb8-39b514a2659d]
And of course you have make sure you have tokenized those ids the right way (not spliting on the dash etc)

Sort or filter results by function query defined in a field

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)

Solr - get range facets inferior to a threshold

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]

Returning the number of documents in solr when result set is grouped and the group is limited

I am using grouping in solr to determine the number unique values in a specific column and the total number of documents for the query. This number is returned using the group.ngroup=true method in the request. This means the result returns ngroup=30000 and matches=500000
This is good until the number of documents returned per group is limited (and the limit would be fixed). e.g If I were to pull all records (hypothetically I am not saying this will be done) from this result set each group would be limited to group.limit=#
If I am only returning two documents (group.limit=2) per group out of a possible range of documents per group of 1 to 20 this obviously means that the total number of documents returned for this select when limited is between 1*ngroup and 2*ngroup
The question is how do I return the exact number of documents returned based on group.limit? as opposed to the range.
For now, there doesn't seem to be an option to get the exact number of documents returned when we use grouping.
The response field "matches" and "numFound" returns the number of docs
matched but not the number of docs returned in response as per
your limiting based on group.limit parameter.
This could be a "good to have" feature in forthcoming Solr releases.

Resources