Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jedis.hset(String, Map<String, Object> is not available in Jedis API #116

Open
shannonantony opened this issue Aug 2, 2020 · 5 comments

Comments

@shannonantony
Copy link

Hi,

I am not able to run the sample as per https://github.com/RediSearch/JRediSearch example with respect to

try(Jedis conn = client.connction()){
conn.hset("item", fields);
}

As per Jedis API, fields should be a Map<String, String>

can you please clarify and help

thanks

Jay

@gkorland
Copy link
Contributor

gkorland commented Aug 3, 2020

Yes field should be a Map<String, String>.
See: https://www.javadoc.io/static/redis.clients/jedis/3.3.0/redis/clients/jedis/Jedis.html#hset-java.lang.String-java.util.Map-
e.g.

Map<String, String> fields = new HashMap<>();
map.put("first", "Ron")
map.put("last", "Kor")

@shannonantony
Copy link
Author

Thanks @gkorland . Does that mean we can not use this API to write/read Numeric fields which are defined in Redisearch Schema?
How do we handle this scenario of dealing with non text fields which are part of schema?

thanks

Jay

@gkorland
Copy link
Contributor

gkorland commented Aug 4, 2020

@shannonantony you're right I guess the Jedis API could be better, but in your case all you need to do is to

Map<String, String> fields = new HashMap<>();
map.put("first", "Ron")
map.put("last", "Kor")
map.put("age", String.valueOf​(age))

@shannonantony
Copy link
Author

Thank you very much for quick response @gkorland . That is what I was thinking too as a work around, but I just wanted to double check. I will test it out and see.

@sazzad16
Copy link
Collaborator

From now on, ClientUtil.toStringMap(...) should come in handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants