I am trying to use Semantic Knowledge Graph in my java based application.

I have a Semantic Knowledge Graph query which works fine if I trigger it
through browser using restlet client. Following is the query.

{
  "queries": [
    "foo:\"5a6127a7234e76473a816f1c\""
  ],
  "compare": [
    {
      "type": "bar",
      "limit": 30
    }
  ]}

Now, I want to trigger the same query through SolrJ client. I have tried
following code but it gives me an error

{"error":{"msg":"KnowledgeGraphHandler requires POST data","code":400}}

The code in java is

    SolrQuery request = new SolrQuery();
    request.setRequestHandler("/skg");
    request.setShowDebugInfo(true);
    request.setParam("wt", "json");
    request.setParam("json",
"{\"queries\":[\"foo:\\\"5a6127a7234e76473a816f1c\\\"\"],\"compare\":[{\"type\":\"bar\",\"limit\":30}]}");
    request.set("rows", 10);
    request.setParam("qf", "conceptname^10 tags^3 textproperty^2 file_text^4");
    try {
        QueryResponse response =
getStore().getEnvironment().getSolr().query(request,
SolrRequest.METHOD.POST);
        NamedList<Object> rsp = response.getResponse();

        ArrayList<SimpleOrderedMap<Object>> skg_resp =
(ArrayList<SimpleOrderedMap<Object>>) rsp.get("clusters");

        if (skg_resp != null) {

        }
    }

Any idea what is wrong here? Any pointer to documentation on how to
construct request for Semantic Knowledge Graph through solrJ would be very
helpful.

Thanks

Pratik

Reply via email to