Redis client search (client.java) returns certain special characters in encoded format

Hi,

I use redis java module.
While searching, certain special characters (&,’) are returned in encoded format.
It does not happen with all the values.

Example:
I have two values in my table. “B\&lore” and “B\@lore”.
I use search function from client.java.
cl.search(query).

The output is different for both.
Former returns Bu0026lore. Later one is B@lore.

Can you please share code example in Java? Including example query?

import io.redisearch.Query;
import io.redisearch.SearchResult;
import io.redisearch.client.Client;
import io.redisearch.Document;

Schema sc = new Schema();;
Client cl = new Client(idx,redisCluster,sentinels,conTimeOut,poolSize);;

sc = sc.addTextField(“type”,5.0)
.addTextField(“value”, 5.0)

Map <String,Object> fields = new HashMap<>();
fields.put(“type”,“test”);
fields.put(“value”,“B&lore”);
status= cl.addDocument(“Sample”,1,fields,false,true,null);

Query q = new Query("*");
SearchResult res= cl.search(q,cl);

When I print res.docs, I face the above issue. Though it is saved as “B&lore” in the redis data base. Search result has the unicode format instead of user input.

It seems like a bug in the Document toString() function, it tries to encode the document as legal JSON and encode & as u0026.
But the results seem OK.

res.docs.get(0).get("value");

Returns "B&lore"