Reputation: 21
Below command return expected result (places names having prefix 'new alban') when executed in the REDIS CLI.
127.0.0.1:6379> zrangebylex my_places_data_set "[new alban" "[new alban\xff"
But when this command is called using jedis api, it's not returning any result for above prefix but returns if i complete the word.
NO RESULT - pipeline.zrangeByLex(my_places_data_set, "[new alban", "[new alban\xff", 0, 5);
RETURN RESULT - pipeline.zrangeByLex(my_places_data_set, "[new albany", "[new albany\xff", 0, 5);
If i use xff instead of \xff following happens
NO RESULT - pipeline.zrangeByLex(my_places_data_set, "[new alban", "[new albanxff", 0, 5);
RETURN RESULT - pipeline.zrangeByLex(my_places_data_set, "[new albany", "[new albanyxff", 0, 5);
RETURN RESULT - pipeline.zrangeByLex(my_places_data_set, "[new albany", "[new albaxff", 0, 5);
P.S. Jedis api signature : zrangeByLex(String key, String min, String max, int offset, int count)
Upvotes: 1
Views: 466
Reputation: 21
I solved this issue by manually appending hex code to prefix
byte[] prefixByte = ("[" + prefix).getBytes();
byte[] prefixByteExtended = Arrays.copyOf(prefixByte, prefixByte.length + 1);
prefixByteExtended[prefixByte.length] = (byte) 0xFF;
pipeline.zrangeByLex(my_places_data_set, ("[" + prefix), new String(prefixByteExtended), 0, 5));
Upvotes: 1