Syntax for Solr Query with Cassandra Datastax integration - solr

I'm trying to use DataStax Cassandra/Solr integration to do a facet query with both pivot facets and interval facets
My query look like this:
select * from data where solr_query='{"facet":{"limit":5,"pivot":"event_type,key","interval":"past_visits","f.past_visits.facet.interval.set":["{!key=visit_13_month}[NOW-13MONTH/MONTH,NOW]","{!key=visit_1_month}[NOW-1MONTH/DAY,NOW]"]},"q":"*:*"}']
The error that I am getting back seems to show that the required parameter is not being set (but it is)
08:30:38.244 [New I/O worker #4] WARN c.d.driver.core.RequestHandler - /10.239.133.151:9042 replied with server error (Missing required parameter: f.past_visits.facet.interval.set (or default: facet.interval.set)), trying next host.
When i run an equivalent query directly to Solr (using query params), it works as expected.
/data/select?q=*:*&facet=true&facet.pivot=event_type,key&facet.limit=5&facet.interval=past_visits&f.past_visits.facet.interval.set=%7B!key=visit_13_month%7D[NOW-13MONTH/MONTH,NOW]&f.past_visits.facet.interval.set=%7B!key=visit_1_month%7D[NOW-1MONTH/DAY,NOW]"
I'm trying to follow the Datastax documentation at this link:
http://docs.datastax.com/en/datastax_enterprise/4.8/datastax_enterprise/srch/srchJSON.html
There seems to be something wrong with the way that I am creating the JSON for the Datastax Solr query, but I do not see what I should change.

We don't currently support facet intervals via CQL. Anyway, you don't need to repeat "facet", so it should eventually be something like the following:
select * from data where solr_query='{"facet" {"limit":5,"pivot":"event_type,key","interval":"past_visits","f.past_visits.interval.set":["{!key=visit_13_month}[NOW-13MONTH/MONTH,NOW]","{!key=visit_1_month}[NOW-1MONTH/DAY,NOW]"]},"q":"*:*"}']

Related

Why dismax q.alt doesn't return any result

I'm new to solr.
After following the tutorial exercise 1(https://solr.apache.org/guide/8_9/solr-tutorial.html), I'm able to do some solr query on my loacl machine.
If I want to get result without condition, I will do the query like
http://127.0.0.1:8983/solr/#/techproducts/query?q=*:*&q.op=OR
This works pretty fine.
But when I switch to "dismax" and try to have similar result, I do need to use "q.alt".
The query is like
http://127.0.0.1:8983/solr/#/techproducts/query?q.op=OR&defType=dismax&q.alt=*:*
However, this query resulted in no result, which is pretty weird.
Even thought I specified the row, it still won't work.
http://127.0.0.1:8983/solr/#/techproducts/query?q.op=OR&defType=dismax&q.alt=*:*&row=0
Does anyone face the same problem before?
These parameters are not meant to be used with the user interface URLs; they're for sending directly to Solr. The user interface is a Javascript interface that talks to the Solr API behind the scenes. You can see that your urls have a local anchor in them (#), and this is just references that the javascript based user interface uses to load the correct page.
The rows parameter is also named rows, not row - and when used with 0, no documents will be returned (in the example it's given as an example for using facets with complete counts - you have to ask for facets for that to make sense).
The actual URL to query Solr for matching documents would be:
http://127.0.0.1:8983/solr/techproducts/select?defType=edismax&q.alt=*:*
This URL is shown in the user interface over the query results when using the query page.
There is also usually no reason to use dismax and not edismax these days, as edismax does everything that the old dismax handler did and with more functionality.

Solr 4.2.1 and SOLR-1604 : ComplexPhrase AND date range queries do not work together

I recently patched my Solr 4.2.1 with the ComplexPhrase query addon (https://issues.apache.org/jira/browse/SOLR-1604). When I issue a query such as :
my_text_field:"testin* compl*"~1 AND my_date_field:2013-12-12T04:58:53.732Z
I get results that contain the text query I issued and the date I issued in the my_date_field.
But when I do this:
my_text_field:"testin* compl*"~1 AND my_date_field:[2013-01-01T02:58:53.732Z TO 2013-12-12T04:58:53.732Z]
I get no results.
If I remove the complexphrase parser things go back to normal ( but I have no support for complex phrase queries ).
Ok after some time reading the lucene and solr code I figured it out.
This patch creates a Query Parser that extends the Lucene QueryParser. The Lucene QueryParser does not handle range queries other than Term Ranges ( simple strings in a way ). If one wants to specialize the behavior of the QueryParser, he must extract the field type and create the appropriate range query ( eg NumericRangeQuery for numbers, etc).

Solr 4 - query with both group.facet and group.func fails

When doing a search like
http://localhost:8983/solr/select?group=true&group.func=product(fildname1,fieldname2)&group.facet=true&facet=true&facet.field=fieldname3
an error is returned in response where facets are normally returned:
java.lang.ArrayIndexOutOfBoundsException: 0 at org.apache.solr.request.SimpleFacets.getGroupedCounts(SimpleFacets.java:358) ...
The function used can be any function, not product only. There is no such error if group.facet is omitted or group.field is used instead of group.func. It seems that group.field parameter is expected to be defined when calculating grouped facets.
The question: is there another way to use both query functions, or an appropriate work-around, or a tip on where in Solr source to look into this?
This question cross posted from a Solr Jira issue 3742. This issue relates to Solr 4 beta that launched very recently.

Solr get calculated distance while using dismax

I'm starting to think that what I want to do is not possible but thought I would give this a try.
I'm running Solr 3.5.
I currently have two types of search:
A basic spatial query which returns the calulated distance between two points in the score field.
Sample Query from my Solr logs:
?fl=*,score&sort=score+asc&start=0&q={!func}geodist()&sfield=coordinates&pt=59.2363514,18.092783&version=2
A dismax query which allows free text queries on a number of fields.
Sample Query from Solr log:
mm=1&d=100.0&sfield=coordinates&qf=field1^5.0+fields2^3.0&defType=edismax&version=2&fl=*,score&start=1&q=monkeyhopper&pt=59.2363514,18.0927830000&fq={!geofilt}}
I want to replace my first query with the dismax query but I really need to get the calculated distance in the response. Yes, I can calulate the distance programatically but I would prefer not having to do this as Solr has done it for me already.
I still want to be able to sort my dismax query "by relevance", distance or any other field so the score given by my boosts could be interesting for sorting but I don't need it to be returned.
If I understood correctly you want to have the result of a function in your Solr response. The SOLR-2444 issue is what you're looking for I guess: it allows to include in the fl parameter pseudo-fields, functions etc. The only problem is that it's been committed only on trunk, so it isn't available on the current Solr release, neither will be in the coming 3.6 release. You have to wait for the 4 release but I don't think it will take a lot of time. Maybe you can already start playing around with a snapshot of the last successful Jenkins build.
Pseudo-fields are now available in Solr 4+ which allow you to do just this.
http://localhost:8983/solr/collection1/browse?q=*:*&rows=1000&wt=xml&pt=37.763649,-122.24313&sfield=store&fl=dist:geodist()
For instance, this request allows me to return a field "dist" which contains the distance of each entry to the stated point.

Field grouping in SolrNet?

I am trying to make a query in solr.net that generates a solr query with a filter query with more than one term in it e.g.: fq=Size:(4 large)
However, when I pass ?f_Size=(4 large) in the query string to the SolrNet sample app (found here: http://code.google.com/p/solrnet/downloads/list), no results are found.
Looking at the logs, I can see that the filter query generated is fq=Size:"\(4+large\)" so it makes sense that no results are found.
Is there a way in SolrNet to generate a filter query with more than one term?
Where the filter queries are built, try replacing Query.Field(...).Is(...) with Query.Simple(...) (you have to build the query yourself). See the wiki for reference.

Resources