POST json request to Solr with cursorMark in request - solr

Is it possible to include cursorMark value in POST request's body instead of sending it as query string parameter?
The following query:
{"query":"val:abc","limit":10,"cursorMark":"*","sort":"id asc"}
returns an error with the message: "Unknown top-level key in JSON request : cursorMark"

According to Solr Json Request API documentation, every query string parameter has a corresponding POST request parameter in JSON API, e.g. q -> query, start -> offset, etc.
However, there is no equivalent parameter for cursorMark query string parameter.
The best solution I am aware of is changing request type from application/json to application/x-www-form-urlencoded which allows using query string parameters in POST request's body. The reason why I was using application/json was to get json response, but it turns that it is controlled by wt=json parameter.
Changed query uri to: http://localhost:8983/solr/myCore/select?wt=json
Changed POST request parameters back to query string counterparts, i.e. q, start, rows, etc.
UrlEncoded the query string.
Put the encoded query string in POST body.
Changed request content type to application/x-www-form-urlencoded.

https://solr.apache.org/guide/7_7/json-request-api.html#passing-parameters-via-json says that you can augment a JSON-based POST with non-JSON params. I got this to work in 2022 with a JSON query that includes "params": {"cursorMark": "*"}, without needing to resort to changing the request type (as suggested in the accepted answer).

Related

Coinbase Pro API GET request returning 400 for /fils and /orders when supplying query parameters

I am attempting to make a GET request for the /fills and /orders endpoints and it works if I do not add query parameters, however, if I add the query parameter "product_id=ETH-USD," I then receive a 400 response with an empty message. Is there anything else I need to do to the Authorization Header when making a GET request with query parameters?
Works: https://api.pro.coinbase.com/fills
400 Response: https://api.pro.coinbase.com/fills?product_id=ETH-USD
So the answer to my question is yes, the Authorization header needs the Body section even for the GET request. The Body section, in this instance, should have ?product_id=ETH-USD in the header signature.

Get query(search handler) configuration for a query using SolrJ

Is it possible to get the query configuration values(default + request parameters) using SolrJ ?
For example: If I direct a request to the RequestHandler using SolrJ, I would like to get a list of parameters(default + overridden request parameters) used on the query. I need this to log the current configuration when the query was made.
Try adding the parameter echoParams=all.
The echoParams parameter tells Solr what kinds of Request parameters
should be included in the response for debugging purposes, legal
values include:
none - don't include any request parameters for debugging
explicit -
include the parameters explicitly specified by the client in the
request
all - include all parameters involved in this request, either
specified explicitly by the client, or implicit because of the request
handler configuration.
Take a look at Common Query Parameters

How do I overwrite Camel Body?

I have used other integration frameworks and libraries before, and in general the way they deal with the message body or payload is to drop everything except the most recent "update" so to speak. Here is an example of what I mean:
XML Message from Queue (payload is XML message) -> use XPath to get something out of XML (payload still XML message) -> Call to some REST API (payload still XML message) -> Return from REST API (payload is now whatever the REST API returned)
I am looking for this sort of behavior in Camel. Right now what Camel is doing is after the "Return from REST API", the payload is whatever the REST API returned appended with the original XML message.
What is the best way for me to only refer to the payload/body that the REST API returns?
Exchange body {exchange.getIn().getBody()} will only contain the response of REST API. Please check the API how it is forming response, it may be appending input xml to output.

GetFeedSubmissionResult is not Giving data in response

I have tried to call GetFeedSubmissionResult api of Amazon MWS Feed submission. i have one Feedsubmissionid which is successfully gives response in "Amazon MWS Scratchpad"
but
In this when i am passing the feedsubmissionid into this api it gives below response,
Service Response=============================================================================
GetFeedSubmissionResultResponse
GetFeedSubmissionResult ContentMd5 YQtHphFPLIcA4vEOn2guCQ==
ResponseMetadata
RequestId
4f715dcf-9e89-4ad5-b721-5bb1ba6bbafa
ResponseHeaderMetadata: RequestId: 4f715dcf-9e89-4ad5-b721-5bb1ba6bbafa, ResponseContext : H5F8Si8GvjCkIIlV+vqovD1zOzXDQ+i7/xRZB46IM/XgePQAAliUi6NzK7tCrVsHM/fZFLhjQkM 0Tvk46V5dJCSmZr22uad,2LvooKOfZwPK75jMl3gDmvuK1oCUt3JWf9UvVTFfXSIhrMpIxkcjQp/ekS0I2neiRcoh0X14RWs0 na0j6cY9ZQ==, Timestamp: 2016-03-09T06:55:38.418Z
Please provide solution as soon as possible.
I get the result in correct format using CURL. I have call API using CURL and i am getting the response in XML format which is actual response.

quoted format json from Solrj

It looks like the QueryResponse from Solrj has no mean to give you a quoted Json string with wt=on or not. All I received is something like this
{responseHeader={status=0,QTime=2,params= {fl=id,productName,imageFront,priceEng,priceEngExp...
Question:
1) Am I missing something here ? Or there is no way to get the json response properly from the Solr server by Solrj.
2) Now on my client, if I convert the non-quoted json string from Solrj, does it mean it was done two times, once in server time and one in the Solrj client time ?
You can get JSON response by setting wt=json to the Solr query. Example URL is shown below :
localhost:8983/solr/select/?q=:&rows=10&indent=on&wt=json
You can't get JSON response using Solrj. You don't need to use Solrj for this purpose.By sending HTTP requests to the URL above, you can get json response.
With newer versions of Solr (starting with 4.7.0) it is possible to return the query response directly in json-format. This can be done with the NoOpResponseParser.
SolrQuery query = new SolrQuery();
QueryRequest req = new QueryRequest(query);
NoOpResponseParser rawJsonResponseParser = new NoOpResponseParser();
rawJsonResponseParser.setWriterType("json");
req.setResponseParser(rawJsonResponseParser);
NamedList<Object> resp = mySolrClient.request(req);
String jsonResponse = (String) resp.get("response");
System.out.println(jsonResponse );

Resources