获取xml作为响应而不是作为Solr {J}的JSON

时间:2017-07-03 09:19:51

标签: solr

从Solr索引记录中获取xml响应而不是JSON响应 我得到xml作为查询字符串的响应,我想有json格式。

我在传递给查询字符串时设置了 wt = json 。我正在用scala代码编写来通过 REST API 从solr获取数据。

这是我的代码。

val qp = s"""full-name:"Jon Snow"""" +"&"+ "wt=json"
    buf = buf.append(URLEncoder.encode(qp  , "UTF-8") + "&")
    val queryparams = buf.toString
    val queryString = queryparams.substring(0, queryparams.length() - 1);
    val urlEncoded: String `enter code here`="http://solr:8983/solr/lily_entity_APPLICATION_shard1_replica1/select?q=" + queryString;

val connection = (new [enter image description here][1]URL(urlEncoded)).openConnection.asInstanceOf[HttpURLConnection]
      connection.setRequestMethod("GET")
      val inputStream = connection.getInputStream
       val content = Source.fromInputStream(inputStream).mkString

Plz帮助

0 个答案:

没有答案