i have vespa verion 5.220.14 installed in one server where i have used json (provided by gson lib ) in searcher, while i am deploying the same code in vespa version 5.550 in a diffrentserver it is not working and changing it to string.
Attached are the screenshot for same.
What could be the possible reason for same,
And what should be resolution to make this work.
Asked
Active
Viewed 111 times
0

divyansh
- 23
- 1
- 4
-
I assume these are 7.* versions, not 5.* versions? – Jon Jan 31 '22 at 19:26
-
Is this a hit generated by Vespa content, or is it perhaps added in code by DedupeIndividualSearcher? If the former, how is the "data" field defined in your schema in the application package. If the latter, what does the code that adds this data look like? – Jon Jan 31 '22 at 19:28
-
JsonObject resdata = root.get("responseData").getAsJsonObject(); JSONObject newroot = new JSONObject(resdata.toString()); hit.setField("data", newroot); hit.setField("responseCode", root.get("responseCode").getAsInt()); this is how we have implemented the code to add data as a json object in vespa logs its a json object only but in postman its string – divyansh Jan 31 '22 at 19:36
2 Answers
2
special-handling of org.json in rendering was removed one year ago:
you should probably wrap your "data" field in a facade that implements the com.yahoo.data.JsonProducer interface:
https://javadoc.io/doc/com.yahoo.vespa/container-search/latest/com/yahoo/data/JsonProducer.html

Arne
- 76
- 2
-
Hi Arne thanks for the response could you please share us the dependency to com.yahoo.data as its giving me plugin error – divyansh Feb 01 '22 at 06:00
1
Arne is correct, we had to move this due to the license of org.json, sorry for the inconvenience.
To implement Arne's solution, all you need is to replace hit.setField("data", newroot); in your code by
hit.setField("data", (com.yahoo.data.JsonProducer)s -> s.append(resdata));

Jon
- 2,043
- 11
- 9