Commit f6e252f8 by nikhilbonte Committed by Ashutosh Mestry

ATLAS-3504-DSL-query-with-like-clause-returns-unexpected-results-v1.patch

parent 9115e7d2
...@@ -24,6 +24,8 @@ import java.io.IOException; ...@@ -24,6 +24,8 @@ import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
...@@ -1077,6 +1079,10 @@ public class Solr6Index implements IndexProvider { ...@@ -1077,6 +1079,10 @@ public class Solr6Index implements IndexProvider {
} else if (AttributeUtil.isDecimal(dataType)) { } else if (AttributeUtil.isDecimal(dataType)) {
if (dataType.equals(Float.class)) postfix = "_f"; if (dataType.equals(Float.class)) postfix = "_f";
else postfix = "_d"; else postfix = "_d";
} else if (dataType.equals(BigInteger.class)) {
postfix = "_bi";
} else if (dataType.equals(BigDecimal.class)) {
postfix = "_bd";
} else if (dataType.equals(Geoshape.class)) { } else if (dataType.equals(Geoshape.class)) {
postfix = "_g"; postfix = "_g";
} else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) {
...@@ -1086,6 +1092,7 @@ public class Solr6Index implements IndexProvider { ...@@ -1086,6 +1092,7 @@ public class Solr6Index implements IndexProvider {
} else if (dataType.equals(UUID.class)) { } else if (dataType.equals(UUID.class)) {
postfix = "_uuid"; postfix = "_uuid";
} else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key);
if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) {
postfix += "s"; postfix += "s";
} }
......
...@@ -134,6 +134,14 @@ public class DSLQueriesTest extends BasicTestSetup { ...@@ -134,6 +134,14 @@ public class DSLQueriesTest extends BasicTestSetup {
@DataProvider(name = "comparisonQueriesProvider") @DataProvider(name = "comparisonQueriesProvider")
private Object[][] comparisonQueriesProvider() { private Object[][] comparisonQueriesProvider() {
return new Object[][] { return new Object[][] {
{"Person where (name = \"Julius\" )", 1},
{"Person where (name like \"Jul*\" )", 1},
{"Person where (name like \"J*\" )", 3},
{"Person where (name like \"*us\" )", 1},
{"Person where (name like \"*uli*\" )", 1},
{"Person where (name like \"Julius\" )", 1},
{"Person where (name like \"Jul\" )", 0},
{"Person where (birthday < \"1950-01-01T02:35:58.440Z\" )", 0}, {"Person where (birthday < \"1950-01-01T02:35:58.440Z\" )", 0},
{"Person where (birthday > \"1975-01-01T02:35:58.440Z\" )", 2}, {"Person where (birthday > \"1975-01-01T02:35:58.440Z\" )", 2},
{"Person where (birthday >= \"1975-01-01T02:35:58.440Z\" )", 2}, {"Person where (birthday >= \"1975-01-01T02:35:58.440Z\" )", 2},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment