通过请求中的cursorMark将JSON请求发布到Solr [英] POST json request to Solr with cursorMark in request

查看:133
本文介绍了通过请求中的cursorMark将JSON请求发布到Solr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将cursorMark值包含在POST请求的正文中,而不是将其作为查询字符串参数发送?

Is it possible to include cursorMark value in POST request's body instead of sending it as query string parameter?

以下查询:

{"query":"val:abc","limit":10,"cursorMark":"*","sort":"id asc"}

返回以下错误消息:"JSON请求中的未知顶级密钥:cursorMark"

推荐答案

根据 Solr Json Request API文档,每个查询字符串参数在 JSON API中都有一个对应的POST请求参数,例如 q->查询开始->偏移量,等等.

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.

但是,没有 cursorMark 查询字符串参数的等效参数.

However, there is no equivalent parameter for cursorMark query string parameter.

我知道的最好的解决方案是将请求类型从 application/json 更改为 application/x-www-form-urlencoded ,该类型允许在POST中使用查询字符串参数请求的正文.我之所以使用 application/json 的原因是为了获得json响应,但事实证明它是由 wt = json 参数控制的.

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. 将查询uri更改为: http://localhost:8983/solr/myCore/选择?wt = json
  2. 将POST请求参数更改回查询字符串,即q,开始,行等.
  3. 使用网址对查询字符串进行编码.
  4. 将编码的查询字符串放在POST正文中.
  5. 已将请求内容类型更改为 application/x-www-form-urlencoded .
  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.

这篇关于通过请求中的cursorMark将JSON请求发布到Solr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆