Solr Json Support - solr

Solr provides way to query in JSON Format -
curl http://localhost:8983/solr/techproducts/query -d '
{
"query" : "memory",
"filter" : "inStock:true"
}'
Can I just pass this json as it is to SOLRJ Client. I need to intercept the request and pass it as it is.

SolrJ client send queries as url parameters (q=memory&fq=inStock:true) and response type is javabin https://wiki.apache.org/solr/javabin
You can use apache http client and set your JSON query and fire request to Solr.

Essentially, we can also set the parameter "json" and the query in SolrJ SolrQuery:
SolrQuery.add("json", "{json query here}")

Related

OSRM: Getting output in Flatbuffers format for route service

I hosted osrm v5.24.0 on my local machine using a dataset preprocessed with CH (Contraction Hierarchies) pipeline. And I need to get the output of route response in flatbuffers format. But I couldn't find the correct query for that.
API Documentation reference: http://project-osrm.org/docs/v5.24.0/api/#requests
osrm request
Query I am using (Postman):
/route/v1/driving/73.14568712144677,-0.6875788801118562;73.13504135080412,-0.682499947378062?overview=full&alternatives=false&steps=false&geometries=geojson&format=flatbuffers
Result I get:
{
"message": "Query string malformed close to position 156",
"code": "InvalidQuery"
}
This is resolved. Following is the correct get request to get the response in flatbuffers format.
Get Request:
/route/v1/driving/73.14568712144677,-0.6875788801118562;73.13504135080412,-0.682499947378062.flatbuffers?overview=full&alternatives=false&steps=false&geometries=geojson

splitResults option shows unknown in apache camel google-sheets-stream component

I'm using apache camel google-sheets-stream component to read google sheet and it is working fine, but I want to split the body into rows and columns, there is an option called "splitResults" given in camel doc, but when I'm using that option it throws "unknown parameters" error.
Does anybody have any idea about this?
Below is my camel route:
from uri="google-sheets-stream://spreadsheets?accessToken=MY_TOKEN_HERE&clientId=MY_CLIENT_ID&clientSecret=MY_CLIENT_SECRET&applicationName=CamelGoogleApp&refreshToken=1/zwgy73W-pcNoCtbOxs_t4b0&spreadsheetId=1hkw_0oOaQDIRZVX_19LpywE&range=Form Responses 1"
Camel Doc that I followed :
https://github.com/apache/camel/blob/master/components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc
Camel google-sheet Version: 2.24.1
Log:
There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{splitResults=true}]
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:209)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1143)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3729)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3443)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3251)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3247)

Apache Solr JSON Querying Local Params

In the Solr documentation it focuses explanations on how to use the GET parameters to define queries, but gives very little information on how to accomplish the same tasks using the better structured JSON POST support. I have been unable to find any documentation that goes deeper than very surface-level explanation.
Particularly, I'm trying to utilize local params in my queries and would like to know how to accomplish the following using a JSON POST instead of GET params:
http://localhost:8983/solr/city/query?sort={!sfield=location pt=35.5514,-97.4075}geodist() asc&q={!geofilt sfield=location pt=35.5514,-97.4075 d=5}
According to JSON Request API / Parameters Mapping your query would map to:
{
"sort": "{!sfield=location pt=35.5514,-97.4075}geodist() asc",
"query": "{!geofilt sfield=location pt=35.5514,-97.4075 d=5}"
}
Just to complete #MatsLindh answer, you can use usual parameter names as long as you wrap them in params (no mapping needed), for example :
file.json
{
"params": {
"q":"{!geofilt sfield=location pt=35.5514,-97.4075 d=5}",
"sort":"{!sfield=location pt=35.5514,-97.4075}geodist() asc",
"wt": "json",
"indent": "true"
}
}
Request example using curl :
curl -H "Content-Type: application/json" -X "POST" --data #file.json http://localhost:8983/solr/city/query

Zuul url parameters to Solr Query parameters

I am trying to rewrite request with zuul and forward them to an old solr server.
My application.yml looks like this:
zuul:
prefix: /api/v1
routes:
peoples:
path: path: /peoples/**
url: http://solr/api/select?
So far the /people route is working fine, i get the incoming request, pass the correct parameters to the request via a Zuulfilter and forward to solr. The redirected request looks:
http://sorl/api/select?q=*&wt=json&indent=true&collection=MyCollection&fl=Filter1,Filter2,Filter3,Filter4&rows=10
I don't understand how i can define a new route like : peoples/{id}.
I need to pass the {id} route to another ZuulFilter and append it to com.netflix.zuul.context.RequestContext.getCurrentContext().setRequestQueryParams()
Am i missing something in Zuul or is it just no possible to get a param from the requestcontext, and transform it to a query param ?

How can we change value openSearcher=true from JAVA Code?

I am trying to insert data to SOLR using HardCommit. By default value of openSearcher=false in solrConfig.xml. I want to change openSearcher=true through JAVA code. Donot want to make change to SOLR.config.xml. Is there any way to do that??
Thanks
You should be able to do that with Config API. You could check current configuration by firing GET request at /config endpoint. E.g
http://localhost:8983/solr/collection-name/config
and set some property with command like this:
curl http://localhost:8983/solr/collection-name/config
-H 'Content-type:application/json' -d
'{
"set-property": {
"updateHandler.autoCommit.openSearcher": true
}
}'
This could be of course done in Java code, by using some popular HTTP client or by firing your implementation of abstract SolrRequest in SolrJ

Resources