Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POST json request to Solr with cursorMark in request

Tags:

solr

lucene

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"

like image 442
grg Avatar asked Feb 02 '17 16:02

grg


1 Answers

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.

  1. Changed query uri to: http://localhost:8983/solr/myCore/select?wt=json
  2. Changed POST request parameters back to query string counterparts, i.e. q, start, rows, etc.
  3. UrlEncoded the query string.
  4. Put the encoded query string in POST body.
  5. Changed request content type to application/x-www-form-urlencoded.
like image 144
grg Avatar answered Nov 04 '22 14:11

grg