diff --git a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index a396fc546..ff096453f 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -15,6 +15,7 @@ */ package org.redisson.spring.data.connection; +import io.netty.buffer.ByteBuf; import org.redisson.Redisson; import org.redisson.api.BatchOptions; import org.redisson.api.BatchOptions.ExecutionMode; @@ -41,6 +42,10 @@ import org.springframework.data.redis.connection.*; import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.core.types.RedisClientInfo; +import org.springframework.data.redis.domain.geo.BoxShape; +import org.springframework.data.redis.domain.geo.GeoReference; +import org.springframework.data.redis.domain.geo.GeoShape; +import org.springframework.data.redis.domain.geo.RadiusShape; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; @@ -2115,7 +2120,128 @@ public class RedissonConnection extends AbstractRedisConnection { public Long geoRemove(byte[] key, byte[]... members) { return zRem(key, members); } - + + @Override + public GeoResults> geoSearch(byte[] key, GeoReference reference, GeoShape predicate, GeoSearchCommandArgs args) { + Assert.notNull(args, "Args must not be null!"); + Assert.notNull(key, "Key must not be null!"); + Assert.notNull(predicate, "Shape must not be null!"); + Assert.notNull(reference, "Reference must not be null!"); + + List commandParams = new ArrayList<>(); + commandParams.add(key); + + if (reference instanceof GeoReference.GeoCoordinateReference) { + GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference; + commandParams.add("FROMLONLAT"); + commandParams.add(convert(ref.getLongitude())); + commandParams.add(convert(ref.getLatitude())); + } else if (reference instanceof GeoReference.GeoMemberReference) { + GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference; + commandParams.add("FROMMEMBER"); + commandParams.add(encode(ref.getMember())); + } + + if (predicate instanceof RadiusShape) { + commandParams.add("BYRADIUS"); + RadiusShape shape = (RadiusShape) predicate; + commandParams.add(shape.getRadius().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } else if (predicate instanceof BoxShape) { + BoxShape shape = (BoxShape) predicate; + commandParams.add("BYBOX"); + commandParams.add(shape.getBoundingBox().getWidth().getValue()); + commandParams.add(shape.getBoundingBox().getHeight().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } + + if (args.hasSortDirection()) { + commandParams.add(args.getSortDirection()); + } + if (args.getLimit() != null) { + commandParams.add("COUNT"); + commandParams.add(args.getLimit()); + if (args.hasAnyLimit()) { + commandParams.add("ANY"); + } + } + RedisCommand>> cmd; + if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { + cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder); + commandParams.add("WITHCOORD"); + } else { + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(predicate.getMetric()), new GeoDistanceDecoder()); + cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder); + commandParams.add("WITHDIST"); + } + + return read(key, ByteArrayCodec.INSTANCE, cmd, commandParams.toArray()); + } + + @Override + public Long geoSearchStore(byte[] destKey, byte[] key, GeoReference reference, GeoShape predicate, GeoSearchStoreCommandArgs args) { + Assert.notNull(args, "Args must not be null!"); + Assert.notNull(key, "Key must not be null!"); + Assert.notNull(destKey, "DestKey must not be null!"); + Assert.notNull(predicate, "Shape must not be null!"); + Assert.notNull(reference, "Reference must not be null!"); + + List commandParams = new ArrayList<>(); + commandParams.add(destKey); + commandParams.add(key); + + if (reference instanceof GeoReference.GeoCoordinateReference) { + GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference; + commandParams.add("FROMLONLAT"); + commandParams.add(convert(ref.getLongitude())); + commandParams.add(convert(ref.getLatitude())); + } else if (reference instanceof GeoReference.GeoMemberReference) { + GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference; + commandParams.add("FROMMEMBER"); + commandParams.add(encode(ref.getMember())); + } + + if (predicate instanceof RadiusShape) { + RadiusShape shape = (RadiusShape) predicate; + commandParams.add("BYRADIUS"); + commandParams.add(shape.getRadius().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } else if (predicate instanceof BoxShape) { + BoxShape shape = (BoxShape) predicate; + commandParams.add("BYBOX"); + commandParams.add(shape.getBoundingBox().getWidth().getValue()); + commandParams.add(shape.getBoundingBox().getHeight().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } + + if (args.hasSortDirection()) { + commandParams.add(args.getSortDirection()); + } + if (args.getLimit() != null) { + commandParams.add("COUNT"); + commandParams.add(args.getLimit()); + if (args.hasAnyLimit()) { + commandParams.add("ANY"); + } + } + if (args.isStoreDistance()) { + commandParams.add("STOREDIST"); + } + + return write(key, LongCodec.INSTANCE, RedisCommands.GEOSEARCHSTORE_STORE, commandParams.toArray()); + } + + private Metric convert(Metric metric) { + if (metric == Metrics.NEUTRAL) { + return DistanceUnit.METERS; + } + return metric; + } + + private ByteBuf encode(Object value) { + return executorService.encode(ByteArrayCodec.INSTANCE, value); + } + private static final RedisCommand PFADD = new RedisCommand("PFADD"); @Override diff --git a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java index aea0bd717..69d0fdac2 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java +++ b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java @@ -143,7 +143,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); @Override public Flux>>>> geoRadius( @@ -164,13 +164,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements params.add(command.getDistance().getValue()); params.add(command.getDistance().getMetric().getAbbreviation()); - RedisCommand>> cmd; + RedisCommand>> cmd; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { - cmd = new RedisCommand>>("GEORADIUS_RO", postitionDecoder); + cmd = new RedisCommand<>("GEORADIUS_RO", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); - cmd = new RedisCommand>>("GEORADIUS_RO", distanceDecoder); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); + cmd = new RedisCommand<>("GEORADIUS_RO", distanceDecoder); params.add("WITHDIST"); } @@ -206,13 +206,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements params.add(command.getDistance().getValue()); params.add(command.getDistance().getMetric().getAbbreviation()); - RedisCommand>> cmd; + RedisCommand>> cmd; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { - cmd = new RedisCommand>>("GEORADIUSBYMEMBER_RO", postitionDecoder); + cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); - cmd = new RedisCommand>>("GEORADIUSBYMEMBER_RO", distanceDecoder); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); + cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", distanceDecoder); params.add("WITHDIST"); } @@ -265,13 +265,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements commandParams.add("BYRADIUS"); RadiusShape shape = (RadiusShape) command.getShape(); commandParams.add(shape.getRadius().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } else if (command.getShape() instanceof BoxShape) { BoxShape shape = (BoxShape) command.getShape(); commandParams.add("BYBOX"); commandParams.add(shape.getBoundingBox().getWidth().getValue()); commandParams.add(shape.getBoundingBox().getHeight().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } RedisGeoCommands.GeoSearchCommandArgs args = command.getArgs() @@ -286,12 +286,12 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements commandParams.add("ANY"); } } - RedisCommand>> cmd; + RedisCommand>> cmd; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder); commandParams.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder()); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder()); cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder); commandParams.add("WITHDIST"); } @@ -332,13 +332,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements RadiusShape shape = (RadiusShape) command.getShape(); commandParams.add("BYRADIUS"); commandParams.add(shape.getRadius().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } else if (command.getShape() instanceof BoxShape) { BoxShape shape = (BoxShape) command.getShape(); commandParams.add("BYBOX"); commandParams.add(shape.getBoundingBox().getWidth().getValue()); commandParams.add(shape.getBoundingBox().getHeight().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } RedisGeoCommands.GeoSearchStoreCommandArgs args = command.getArgs() @@ -362,4 +362,11 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } + private Metric convert(Metric metric) { + if (metric == Metrics.NEUTRAL) { + return RedisGeoCommands.DistanceUnit.METERS; + } + return metric; + } + } diff --git a/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index b584f4bd3..ebdddbdfc 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -73,6 +73,9 @@ public class RedissonConnectionTest extends BaseConnectionTest { RedisGeoCommands.GeoRadiusCommandArgs args = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeCoordinates(); GeoResults> res = redisTemplate.opsForGeo().radius(key, within, args); assertThat(res.getContent().get(0).getContent().getName()).isEqualTo("a"); + + GeoResults> res2 = redisTemplate.opsForGeo().search(key, within); + assertThat(res2.getContent().size()).isEqualTo(1); } @Test diff --git a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index a396fc546..3eda19263 100644 --- a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -15,6 +15,7 @@ */ package org.redisson.spring.data.connection; +import io.netty.buffer.ByteBuf; import org.redisson.Redisson; import org.redisson.api.BatchOptions; import org.redisson.api.BatchOptions.ExecutionMode; @@ -41,6 +42,10 @@ import org.springframework.data.redis.connection.*; import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.core.types.RedisClientInfo; +import org.springframework.data.redis.domain.geo.BoxShape; +import org.springframework.data.redis.domain.geo.GeoReference; +import org.springframework.data.redis.domain.geo.GeoShape; +import org.springframework.data.redis.domain.geo.RadiusShape; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; @@ -2115,7 +2120,127 @@ public class RedissonConnection extends AbstractRedisConnection { public Long geoRemove(byte[] key, byte[]... members) { return zRem(key, members); } - + + @Override + public GeoResults> geoSearch(byte[] key, GeoReference reference, GeoShape predicate, GeoSearchCommandArgs args) { + Assert.notNull(args, "Args must not be null!"); + Assert.notNull(key, "Key must not be null!"); + Assert.notNull(predicate, "Shape must not be null!"); + Assert.notNull(reference, "Reference must not be null!"); + + List commandParams = new ArrayList<>(); + commandParams.add(key); + + if (reference instanceof GeoReference.GeoCoordinateReference) { + GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference; + commandParams.add("FROMLONLAT"); + commandParams.add(convert(ref.getLongitude())); + commandParams.add(convert(ref.getLatitude())); + } else if (reference instanceof GeoReference.GeoMemberReference) { + GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference; + commandParams.add("FROMMEMBER"); + commandParams.add(encode(ref.getMember())); + } + + if (predicate instanceof RadiusShape) { + commandParams.add("BYRADIUS"); + RadiusShape shape = (RadiusShape) predicate; + commandParams.add(shape.getRadius().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } else if (predicate instanceof BoxShape) { + BoxShape shape = (BoxShape) predicate; + commandParams.add("BYBOX"); + commandParams.add(shape.getBoundingBox().getWidth().getValue()); + commandParams.add(shape.getBoundingBox().getHeight().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } + + if (args.hasSortDirection()) { + commandParams.add(args.getSortDirection()); + } + if (args.getLimit() != null) { + commandParams.add("COUNT"); + commandParams.add(args.getLimit()); + if (args.hasAnyLimit()) { + commandParams.add("ANY"); + } + } + RedisCommand>> cmd; + if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { + cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder); + commandParams.add("WITHCOORD"); + } else { + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(predicate.getMetric()), new GeoDistanceDecoder()); + cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder); + commandParams.add("WITHDIST"); + } + + return read(key, ByteArrayCodec.INSTANCE, cmd, commandParams.toArray()); + } + + @Override + public Long geoSearchStore(byte[] destKey, byte[] key, GeoReference reference, GeoShape predicate, GeoSearchStoreCommandArgs args) { + Assert.notNull(args, "Args must not be null!"); + Assert.notNull(key, "Key must not be null!"); + Assert.notNull(destKey, "DestKey must not be null!"); + Assert.notNull(predicate, "Shape must not be null!"); + Assert.notNull(reference, "Reference must not be null!"); + + List commandParams = new ArrayList<>(); + commandParams.add(destKey); + commandParams.add(key); + + if (reference instanceof GeoReference.GeoCoordinateReference) { + GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference; + commandParams.add("FROMLONLAT"); + commandParams.add(convert(ref.getLongitude())); + commandParams.add(convert(ref.getLatitude())); + } else if (reference instanceof GeoReference.GeoMemberReference) { + GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference; + commandParams.add("FROMMEMBER"); + commandParams.add(encode(ref.getMember())); + } + + if (predicate instanceof RadiusShape) { + RadiusShape shape = (RadiusShape) predicate; + commandParams.add("BYRADIUS"); + commandParams.add(shape.getRadius().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } else if (predicate instanceof BoxShape) { + BoxShape shape = (BoxShape) predicate; + commandParams.add("BYBOX"); + commandParams.add(shape.getBoundingBox().getWidth().getValue()); + commandParams.add(shape.getBoundingBox().getHeight().getValue()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); + } + + if (args.hasSortDirection()) { + commandParams.add(args.getSortDirection()); + } + if (args.getLimit() != null) { + commandParams.add("COUNT"); + commandParams.add(args.getLimit()); + if (args.hasAnyLimit()) { + commandParams.add("ANY"); + } + } + if (args.isStoreDistance()) { + commandParams.add("STOREDIST"); + } + + return write(key, LongCodec.INSTANCE, RedisCommands.GEOSEARCHSTORE_STORE, commandParams.toArray()); + } + + private Metric convert(Metric metric) { + if (metric == Metrics.NEUTRAL) { + return DistanceUnit.METERS; + } + return metric; + } + + private ByteBuf encode(Object value) { + return executorService.encode(ByteArrayCodec.INSTANCE, value); + } private static final RedisCommand PFADD = new RedisCommand("PFADD"); @Override diff --git a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java index aea0bd717..69d0fdac2 100644 --- a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java +++ b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java @@ -143,7 +143,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); @Override public Flux>>>> geoRadius( @@ -164,13 +164,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements params.add(command.getDistance().getValue()); params.add(command.getDistance().getMetric().getAbbreviation()); - RedisCommand>> cmd; + RedisCommand>> cmd; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { - cmd = new RedisCommand>>("GEORADIUS_RO", postitionDecoder); + cmd = new RedisCommand<>("GEORADIUS_RO", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); - cmd = new RedisCommand>>("GEORADIUS_RO", distanceDecoder); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); + cmd = new RedisCommand<>("GEORADIUS_RO", distanceDecoder); params.add("WITHDIST"); } @@ -206,13 +206,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements params.add(command.getDistance().getValue()); params.add(command.getDistance().getMetric().getAbbreviation()); - RedisCommand>> cmd; + RedisCommand>> cmd; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { - cmd = new RedisCommand>>("GEORADIUSBYMEMBER_RO", postitionDecoder); + cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); - cmd = new RedisCommand>>("GEORADIUSBYMEMBER_RO", distanceDecoder); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); + cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", distanceDecoder); params.add("WITHDIST"); } @@ -265,13 +265,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements commandParams.add("BYRADIUS"); RadiusShape shape = (RadiusShape) command.getShape(); commandParams.add(shape.getRadius().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } else if (command.getShape() instanceof BoxShape) { BoxShape shape = (BoxShape) command.getShape(); commandParams.add("BYBOX"); commandParams.add(shape.getBoundingBox().getWidth().getValue()); commandParams.add(shape.getBoundingBox().getHeight().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } RedisGeoCommands.GeoSearchCommandArgs args = command.getArgs() @@ -286,12 +286,12 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements commandParams.add("ANY"); } } - RedisCommand>> cmd; + RedisCommand>> cmd; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder); commandParams.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder()); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder()); cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder); commandParams.add("WITHDIST"); } @@ -332,13 +332,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements RadiusShape shape = (RadiusShape) command.getShape(); commandParams.add("BYRADIUS"); commandParams.add(shape.getRadius().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } else if (command.getShape() instanceof BoxShape) { BoxShape shape = (BoxShape) command.getShape(); commandParams.add("BYBOX"); commandParams.add(shape.getBoundingBox().getWidth().getValue()); commandParams.add(shape.getBoundingBox().getHeight().getValue()); - commandParams.add(shape.getMetric().getAbbreviation()); + commandParams.add(convert(shape.getMetric()).getAbbreviation()); } RedisGeoCommands.GeoSearchStoreCommandArgs args = command.getArgs() @@ -362,4 +362,11 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } + private Metric convert(Metric metric) { + if (metric == Metrics.NEUTRAL) { + return RedisGeoCommands.DistanceUnit.METERS; + } + return metric; + } + }