我正在尝试返回 SOLRDocList 类型的 JSON,即:
{numFound=0,start=0,docs=[]}{"start":0,"empty":true,"class":"class org.apache.solr.common.SolrDocumentList","numFound":0}
但是,由于我将 Service 类用作:
@POST
@Path("/userQuery")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public SolrDocumentList userQuery(String p){
int sizy;
String stry;
StringBuilder sb = new StringBuilder();
SolrDocument doc = null;
SolrDocumentList docList = null;
List<String> arr = new ArrayList();
StringTokenizer token = new StringTokenizer(p,",");
while(token.hasMoreElements()){
stry = token.nextToken();
arr.add(stry);
}
Set<String> xrr = new HashSet<String>(arr);
SolrQuery query = new SolrQuery(createQuery(arr));
query.setIncludeScore(false);
query.setFields("country_code,last_name,raw_location");
query.setParam("wt", "json");
System.out.println(query);
QueryResponse qr = authorSearcher.query(query);
docList = qr.getResults();
return docList;
}
Error is :
SEVERE: A message body writer for Java class org.apache.solr.common.SolrDocumentList, and Java type class org.apache.solr.common.SolrDocumentList, and MIME media type application/json was not found
SEVERE: The registered message body writers compatible with the MIME media type are:
application/json ->
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$App
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$App
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$App
*/* ->
我想知道是否有任何可能的方法可以将 JSON 的 SOLRDocList 类型转换为支持的类型来解决这个问题?谢谢你的时间 !