clean up uuid to string code for index
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a5620799 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a5620799 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a5620799 Branch: refs/heads/USERGRID-933 Commit: a562079989cfe2d9ae46e0f8eb9ac07ded794023 Parents: 968496d Author: Shawn Feldman <sfeld...@apache.org> Authored: Wed Sep 16 07:40:07 2015 -0600 Committer: Shawn Feldman <sfeld...@apache.org> Committed: Wed Sep 16 07:40:07 2015 -0600 ---------------------------------------------------------------------- .../usergrid/persistence/index/impl/EsQueryVistor.java | 12 ++++-------- .../persistence/index/impl/EntityIndexTest.java | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5620799/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java index af60ed6..414f716 100644 --- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java +++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java @@ -361,9 +361,9 @@ public class EsQueryVistor implements QueryVisitor { final String name = op.getProperty().getValue().toLowerCase(); final Object value = op.getLiteral().getValue(); - //special case so we support our '*' char with wildcard + //special case so we support our '*' char with wildcard, also should work for uuids if ( value instanceof String || value instanceof UUID ) { - final String stringValue = (value.toString()).toLowerCase().trim(); + final String stringValue = ((value instanceof String) ? (String)value : value.toString()).toLowerCase().trim(); // or field is just a string that does need a prefix us a query if ( stringValue.contains( "*" ) ) { @@ -503,11 +503,7 @@ public class EsQueryVistor implements QueryVisitor { * Get the field name for the primitive type */ private String getFieldNameForType( final Object object ) { - if ( object instanceof String) { - return IndexingUtils.FIELD_STRING_NESTED; - } - - if(object instanceof UUID){ + if ( object instanceof String || object instanceof UUID) { return IndexingUtils.FIELD_STRING_NESTED; } @@ -540,7 +536,7 @@ public class EsQueryVistor implements QueryVisitor { } if ( input instanceof UUID ) { - return input.toString() ; + return input.toString().toLowerCase() ; } return input; http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5620799/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java index 7aa97b1..6348a44 100644 --- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java +++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java @@ -179,6 +179,7 @@ public class EntityIndexTest extends BaseIT { assertEquals( entity2.getId(), candidate2.getId() ); assertEquals( entity2.getVersion(), candidate2.getVersion() ); + //make sure we can query uuids out as strings and not wrapped candidateResults = entityIndex.search( indexEdge, searchTypes, "select * where testuuid = '"+uuid+"'", 100, 0 ); assertEquals(entity1.getId(),candidateResults.get(0).getId());