Return-Path: X-Original-To: apmail-usergrid-commits-archive@minotaur.apache.org Delivered-To: apmail-usergrid-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 935F217C55 for ; Wed, 1 Oct 2014 14:51:38 +0000 (UTC) Received: (qmail 2746 invoked by uid 500); 1 Oct 2014 14:51:38 -0000 Delivered-To: apmail-usergrid-commits-archive@usergrid.apache.org Received: (qmail 2681 invoked by uid 500); 1 Oct 2014 14:51:38 -0000 Mailing-List: contact commits-help@usergrid.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@usergrid.incubator.apache.org Delivered-To: mailing list commits@usergrid.incubator.apache.org Received: (qmail 2314 invoked by uid 99); 1 Oct 2014 14:51:38 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Oct 2014 14:51:38 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 13AF7882B88; Wed, 1 Oct 2014 14:51:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: snoopdave@apache.org To: commits@usergrid.apache.org Date: Wed, 01 Oct 2014 14:52:01 -0000 Message-Id: In-Reply-To: <68ade1d05fb940afb4b371372ac114b8@git.apache.org> References: <68ade1d05fb940afb4b371372ac114b8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [25/35] git commit: Need to support order by boolean too. Need to support order by boolean too. Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2ea3ee1a Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2ea3ee1a Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2ea3ee1a Branch: refs/heads/two-dot-o-rebuildable-index Commit: 2ea3ee1adde4275e32167d84e3076bfdf7b3f7ad Parents: a05ed4e Author: Dave Johnson Authored: Mon Sep 29 14:50:16 2014 -0400 Committer: Dave Johnson Committed: Mon Sep 29 14:50:16 2014 -0400 ---------------------------------------------------------------------- .../persistence/index/impl/EsEntityIndexImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ea3ee1a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java index 8a1233f..8401e13 100644 --- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java +++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java @@ -411,6 +411,11 @@ public class EsEntityIndexImpl implements EntityIndex { order = SortOrder.DESC; } + // we do not know the type of the "order by" property and so we do not know what + // type prefix to use. So, here we add an order by clause for every possible type + // that you can order by: string, number and boolean and we ask ElasticSearch + // to ignore any fields that are not present. + final String stringFieldName = STRING_PREFIX + sp.getPropertyName(); final FieldSortBuilder stringSort = SortBuilders .fieldSort( stringFieldName ) @@ -426,6 +431,14 @@ public class EsEntityIndexImpl implements EntityIndex { .ignoreUnmapped(true); srb.addSort( numberSort ); log.debug(" Sort: {} order by {}", numberFieldName, order.toString()); + + final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName(); + final FieldSortBuilder booleanSort = SortBuilders + .fieldSort( booleanFieldName ) + .order(order) + .ignoreUnmapped(true); + srb.addSort( booleanSort ); + log.debug(" Sort: {} order by {}", booleanFieldName, order.toString()); } searchResponse = srb.execute().actionGet();