polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [2/2] zest-java git commit: ZEST-177 Rework ElasticSearch EntityStore for ElasticSearch 2
Date Mon, 12 Sep 2016 01:40:35 GMT
ZEST-177 Rework ElasticSearch EntityStore for ElasticSearch 2


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/e6133864
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/e6133864
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/e6133864

Branch: refs/heads/develop
Commit: e6133864e46f21e61c82ee2a0e8cac0d8a27953d
Parents: efe7670
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun Sep 11 18:37:27 2016 -0700
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun Sep 11 18:37:27 2016 -0700

----------------------------------------------------------------------
 .../elasticsearch/ElasticSearchFinder.java      | 209 ++++++++-----------
 .../ElasticSearchFinderSupport.java             |   8 +-
 .../elasticsearch/cluster/ESClusterSupport.java |   9 +-
 .../filesystem/ESFilesystemSupport.java         |   7 +-
 .../internal/AbstractElasticSearchSupport.java  |   4 +-
 .../elasticsearch/memory/ESMemorySupport.java   |   7 +-
 libraries.gradle                                |   2 +-
 7 files changed, 107 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinder.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinder.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinder.java
index c58f524..d1e083d 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinder.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinder.java
@@ -21,18 +21,7 @@ package org.apache.zest.index.elasticsearch;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.function.Function;
 import java.util.function.Predicate;
-import org.elasticsearch.action.count.CountRequestBuilder;
-import org.elasticsearch.action.count.CountResponse;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.index.query.AndFilterBuilder;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.OrFilterBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.sort.SortOrder;
 import org.apache.zest.api.composite.Composite;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
@@ -65,20 +54,23 @@ import org.apache.zest.functional.Iterables;
 import org.apache.zest.index.elasticsearch.ElasticSearchFinderSupport.ComplexTypeSupport;
 import org.apache.zest.spi.query.EntityFinder;
 import org.apache.zest.spi.query.EntityFinderException;
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.sort.SortOrder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.elasticsearch.index.query.FilterBuilders.andFilter;
-import static org.elasticsearch.index.query.FilterBuilders.existsFilter;
-import static org.elasticsearch.index.query.FilterBuilders.missingFilter;
-import static org.elasticsearch.index.query.FilterBuilders.notFilter;
-import static org.elasticsearch.index.query.FilterBuilders.rangeFilter;
-import static org.elasticsearch.index.query.FilterBuilders.regexpFilter;
-import static org.elasticsearch.index.query.FilterBuilders.termFilter;
-import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
+import static org.apache.zest.index.elasticsearch.ElasticSearchFinderSupport.resolveVariable;
+import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
+import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
+import static org.elasticsearch.index.query.QueryBuilders.regexpQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import static org.elasticsearch.index.query.QueryBuilders.wrapperQuery;
-import static org.apache.zest.index.elasticsearch.ElasticSearchFinderSupport.resolveVariable;
 
 @Mixins( ElasticSearchFinder.Mixin.class )
 public interface ElasticSearchFinder
@@ -104,10 +96,10 @@ public interface ElasticSearchFinder
             // Prepare request
             SearchRequestBuilder request = support.client().prepareSearch( support.index()
);
 
-            AndFilterBuilder filterBuilder = baseFilters( resultType );
-            QueryBuilder queryBuilder = processWhereSpecification( filterBuilder, whereClause,
variables );
+            BoolQueryBuilder baseQueryBuilder = baseQuery( resultType );
+            QueryBuilder whereQueryBuilder = processWhereSpecification( baseQueryBuilder,
whereClause, variables );
 
-            request.setQuery( filteredQuery( queryBuilder, filterBuilder ) );
+            request.setQuery( boolQuery().must( whereQueryBuilder ).filter( baseQueryBuilder
) );
             if( firstResult != null )
             {
                 request.setFrom( firstResult );
@@ -135,15 +127,7 @@ public interface ElasticSearchFinder
             // Execute
             SearchResponse response = request.execute().actionGet();
 
-            return Iterables.map( new Function<SearchHit, EntityReference>()
-            {
-                @Override
-                public EntityReference apply( SearchHit from )
-                {
-                    return EntityReference.parseEntityReference( from.id() );
-                }
-
-            }, response.getHits() );
+            return Iterables.map( (SearchHit from) -> EntityReference.parseEntityReference(
from.id() ), response.getHits() );
         }
 
         @Override
@@ -155,10 +139,10 @@ public interface ElasticSearchFinder
             // Prepare request
             SearchRequestBuilder request = support.client().prepareSearch( support.index()
);
 
-            AndFilterBuilder filterBuilder = baseFilters( resultType );
-            QueryBuilder queryBuilder = processWhereSpecification( filterBuilder, whereClause,
variables );
+            BoolQueryBuilder baseQueryBuilder = baseQuery( resultType );
+            QueryBuilder whereQueryBuilder = processWhereSpecification( baseQueryBuilder,
whereClause, variables );
 
-            request.setQuery( filteredQuery( queryBuilder, filterBuilder ) );
+            request.setQuery( boolQuery().must( whereQueryBuilder ).filter( baseQueryBuilder
) );
             request.setSize( 1 );
 
             // Log
@@ -182,28 +166,28 @@ public interface ElasticSearchFinder
             throws EntityFinderException
         {
             // Prepare request
-            CountRequestBuilder request = support.client().prepareCount( support.index()
);
+            SearchRequestBuilder request = support.client().prepareSearch(support.index()).setSize(0);
 
-            AndFilterBuilder filterBuilder = baseFilters( resultType );
-            QueryBuilder queryBuilder = processWhereSpecification( filterBuilder, whereClause,
variables );
+            BoolQueryBuilder baseQueryBuilder = baseQuery( resultType );
+            QueryBuilder whereQueryBuilder = processWhereSpecification( baseQueryBuilder,
whereClause, variables );
 
-            request.setQuery( filteredQuery( queryBuilder, filterBuilder ) );
+            request.setQuery( boolQuery().must(whereQueryBuilder).filter(baseQueryBuilder)
);
 
             // Log
             LOGGER.debug( "Will count Entities: {}", request );
 
             // Execute
-            CountResponse count = request.execute().actionGet();
+            SearchResponse count = request.execute().actionGet();
 
-            return count.getCount();
+            return count.getHits().getTotalHits();
         }
 
-        private static AndFilterBuilder baseFilters( Class<?> resultType )
+        private static BoolQueryBuilder baseQuery( Class<?> resultType )
         {
-            return andFilter( termFilter( "_types", resultType.getName() ) );
+            return boolQuery().must( termQuery( "_types", resultType.getName() ) );
         }
 
-        private QueryBuilder processWhereSpecification( AndFilterBuilder filterBuilder,
+        private QueryBuilder processWhereSpecification( BoolQueryBuilder queryBuilder,
                                                         Predicate<Composite> spec,
                                                         Map<String, Object> variables
)
             throws EntityFinderException
@@ -218,11 +202,11 @@ public interface ElasticSearchFinder
                 return wrapperQuery( ( (QuerySpecification) spec ).query() );
             }
 
-            processSpecification( filterBuilder, spec, variables );
+            processSpecification( queryBuilder, spec, variables );
             return matchAllQuery();
         }
 
-        private void processSpecification( FilterBuilder filterBuilder,
+        private void processSpecification( BoolQueryBuilder queryBuilder,
                                            Predicate<Composite> spec,
                                            Map<String, Object> variables )
             throws EntityFinderException
@@ -230,70 +214,70 @@ public interface ElasticSearchFinder
             if( spec instanceof BinaryPredicate )
             {
                 BinaryPredicate binSpec = (BinaryPredicate) spec;
-                processBinarySpecification( filterBuilder, binSpec, variables );
+                processBinarySpecification( queryBuilder, binSpec, variables );
             }
             else if( spec instanceof Notpredicate )
             {
                 Notpredicate notSpec = (Notpredicate) spec;
-                processNotSpecification( filterBuilder, notSpec, variables );
+                processNotSpecification( queryBuilder, notSpec, variables );
             }
             else if( spec instanceof ComparisonPredicate )
             {
                 ComparisonPredicate<?> compSpec = (ComparisonPredicate<?>) spec;
-                processComparisonSpecification( filterBuilder, compSpec, variables );
+                processComparisonSpecification( queryBuilder, compSpec, variables );
             }
             else if( spec instanceof ContainsAllPredicate )
             {
                 ContainsAllPredicate<?> contAllSpec = (ContainsAllPredicate) spec;
-                processContainsAllSpecification( filterBuilder, contAllSpec, variables );
+                processContainsAllSpecification( queryBuilder, contAllSpec, variables );
             }
             else if( spec instanceof ContainsPredicate )
             {
                 ContainsPredicate<?> contSpec = (ContainsPredicate) spec;
-                processContainsSpecification( filterBuilder, contSpec, variables );
+                processContainsSpecification( queryBuilder, contSpec, variables );
             }
             else if( spec instanceof MatchesPredicate )
             {
                 MatchesPredicate matchSpec = (MatchesPredicate) spec;
-                processMatchesSpecification( filterBuilder, matchSpec, variables );
+                processMatchesSpecification( queryBuilder, matchSpec, variables );
             }
             else if( spec instanceof PropertyNotNullPredicate )
             {
                 PropertyNotNullPredicate<?> propNotNullSpec = (PropertyNotNullPredicate)
spec;
-                processPropertyNotNullSpecification( filterBuilder, propNotNullSpec );
+                processPropertyNotNullSpecification( queryBuilder, propNotNullSpec );
             }
             else if( spec instanceof PropertyNullPredicate )
             {
                 PropertyNullPredicate<?> propNullSpec = (PropertyNullPredicate) spec;
-                processPropertyNullSpecification( filterBuilder, propNullSpec );
+                processPropertyNullSpecification( queryBuilder, propNullSpec );
             }
             else if( spec instanceof AssociationNotNullPredicate )
             {
                 AssociationNotNullPredicate<?> assNotNullSpec = (AssociationNotNullPredicate)
spec;
-                processAssociationNotNullSpecification( filterBuilder, assNotNullSpec );
+                processAssociationNotNullSpecification( queryBuilder, assNotNullSpec );
             }
             else if( spec instanceof AssociationNullPredicate )
             {
                 AssociationNullPredicate<?> assNullSpec = (AssociationNullPredicate)
spec;
-                processAssociationNullSpecification( filterBuilder, assNullSpec );
+                processAssociationNullSpecification( queryBuilder, assNullSpec );
             }
             else if( spec instanceof ManyAssociationContainsPredicate )
             {
                 ManyAssociationContainsPredicate<?> manyAssContSpec = (ManyAssociationContainsPredicate)
spec;
-                processManyAssociationContainsSpecification( filterBuilder, manyAssContSpec,
variables );
+                processManyAssociationContainsSpecification( queryBuilder, manyAssContSpec,
variables );
             }
             else if( spec instanceof NamedAssociationContainsPredicate )
             {
 
                 NamedAssociationContainsPredicate<?> namedAssContSpec = (NamedAssociationContainsPredicate)
spec;
-                processNamedAssociationContainsSpecification( filterBuilder, namedAssContSpec,
variables );
+                processNamedAssociationContainsSpecification( queryBuilder, namedAssContSpec,
variables );
 
             }
             else if( spec instanceof NamedAssociationContainsNamePredicate )
             {
 
                 NamedAssociationContainsNamePredicate<?> namedAssContNameSpec = (NamedAssociationContainsNamePredicate)
spec;
-                processNamedAssociationContainsNameSpecification( filterBuilder, namedAssContNameSpec,
variables );
+                processNamedAssociationContainsNameSpecification( queryBuilder, namedAssContNameSpec,
variables );
 
             }
             else
@@ -304,23 +288,7 @@ public interface ElasticSearchFinder
             }
         }
 
-        private static void addFilter( FilterBuilder filter, FilterBuilder into )
-        {
-            if( into instanceof AndFilterBuilder )
-            {
-                ( (AndFilterBuilder) into ).add( filter );
-            }
-            else if( into instanceof OrFilterBuilder )
-            {
-                ( (OrFilterBuilder) into ).add( filter );
-            }
-            else
-            {
-                throw new UnsupportedOperationException( "FilterBuilder is nor an AndFB nor
an OrFB, cannot continue." );
-            }
-        }
-
-        private void processBinarySpecification( FilterBuilder filterBuilder,
+        private void processBinarySpecification( BoolQueryBuilder queryBuilder,
                                                  BinaryPredicate spec,
                                                  Map<String, Object> variables )
             throws EntityFinderException
@@ -330,21 +298,24 @@ public interface ElasticSearchFinder
 
             if( spec instanceof AndPredicate )
             {
-                AndFilterBuilder andFilterBuilder = new AndFilterBuilder();
+                BoolQueryBuilder andBuilder = boolQuery();
                 for( Predicate<Composite> operand : operands )
                 {
-                    processSpecification( andFilterBuilder, operand, variables );
+                    processSpecification( andBuilder, operand, variables );
                 }
-                addFilter( andFilterBuilder, filterBuilder );
+                queryBuilder.must( andBuilder );
             }
             else if( spec instanceof OrPredicate )
             {
-                OrFilterBuilder orFilterBuilder = new OrFilterBuilder();
+                BoolQueryBuilder orBuilder = boolQuery();
                 for( Predicate<Composite> operand : operands )
                 {
-                    processSpecification( orFilterBuilder, operand, variables );
+                    BoolQueryBuilder shouldBuilder = boolQuery();
+                    processSpecification( shouldBuilder, operand, variables );
+                    orBuilder.should( shouldBuilder );
                 }
-                addFilter( orFilterBuilder, filterBuilder );
+                orBuilder.minimumNumberShouldMatch( 1 );
+                queryBuilder.must( orBuilder );
             }
             else
             {
@@ -353,18 +324,18 @@ public interface ElasticSearchFinder
             }
         }
 
-        private void processNotSpecification( FilterBuilder filterBuilder,
+        private void processNotSpecification( BoolQueryBuilder queryBuilder,
                                               Notpredicate spec,
                                               Map<String, Object> variables )
             throws EntityFinderException
         {
             LOGGER.trace( "Processing NotSpecification {}", spec );
-            AndFilterBuilder operandFilter = new AndFilterBuilder();
-            processSpecification( operandFilter, spec.operand(), variables );
-            addFilter( notFilter( operandFilter ), filterBuilder );
+            BoolQueryBuilder operandBuilder = boolQuery();
+            processSpecification( operandBuilder, spec.operand(), variables );
+            queryBuilder.mustNot( operandBuilder );
         }
 
-        private void processComparisonSpecification( FilterBuilder filterBuilder,
+        private void processComparisonSpecification( BoolQueryBuilder queryBuilder,
                                                      ComparisonPredicate<?> spec,
                                                      Map<String, Object> variables
)
         {
@@ -380,7 +351,7 @@ public interface ElasticSearchFinder
             {
                 // Query on complex type property
                 ComplexTypeSupport support = COMPLEX_TYPE_SUPPORTS.get( spec.value().getClass()
);
-                addFilter( support.comparison( spec, variables ), filterBuilder );
+                queryBuilder.must( support.comparison( spec, variables ) );
             }
             else
             {
@@ -389,29 +360,27 @@ public interface ElasticSearchFinder
                 Object value = resolveVariable( spec.value(), variables );
                 if( spec instanceof EqPredicate )
                 {
-                    addFilter( termFilter( name, value ), filterBuilder );
+                    queryBuilder.must( termQuery( name, value ) );
                 }
                 else if( spec instanceof NePredicate )
                 {
-                    addFilter( andFilter( existsFilter( name ),
-                                          notFilter( termFilter( name, value ) ) ),
-                               filterBuilder );
+                    queryBuilder.must( existsQuery( name ) ).mustNot( termQuery( name, value
) );
                 }
                 else if( spec instanceof GePredicate )
                 {
-                    addFilter( rangeFilter( name ).gte( value ), filterBuilder );
+                    queryBuilder.must( rangeQuery( name ).gte( value ) );
                 }
                 else if( spec instanceof GtPredicate )
                 {
-                    addFilter( rangeFilter( name ).gt( value ), filterBuilder );
+                    queryBuilder.must( rangeQuery( name ).gt( value ) );
                 }
                 else if( spec instanceof LePredicate )
                 {
-                    addFilter( rangeFilter( name ).lte( value ), filterBuilder );
+                    queryBuilder.must( rangeQuery( name ).lte( value ) );
                 }
                 else if( spec instanceof LtPredicate )
                 {
-                    addFilter( rangeFilter( name ).lt( value ), filterBuilder );
+                    queryBuilder.must( rangeQuery( name ).lt( value ) );
                 }
                 else
                 {
@@ -422,7 +391,7 @@ public interface ElasticSearchFinder
             }
         }
 
-        private void processContainsAllSpecification( FilterBuilder filterBuilder,
+        private void processContainsAllSpecification( BoolQueryBuilder queryBuilder,
                                                       ContainsAllPredicate<?> spec,
                                                       Map<String, Object> variables
)
         {
@@ -437,21 +406,21 @@ public interface ElasticSearchFinder
             else if( COMPLEX_TYPE_SUPPORTS.get( firstValue.getClass() ) != null )
             {
                 ComplexTypeSupport support = COMPLEX_TYPE_SUPPORTS.get( firstValue.getClass()
);
-                addFilter( support.containsAll( spec, variables ), filterBuilder );
+                queryBuilder.must( support.containsAll( spec, variables ) );
             }
             else
             {
                 String name = spec.collectionProperty().toString();
-                AndFilterBuilder contAllFilter = new AndFilterBuilder();
+                BoolQueryBuilder contAllBuilder = boolQuery();
                 for( Object value : spec.containedValues() )
                 {
-                    contAllFilter.add( termFilter( name, resolveVariable( value, variables
) ) );
+                    contAllBuilder.must( termQuery( name, resolveVariable( value, variables
) ) );
                 }
-                addFilter( contAllFilter, filterBuilder );
+                queryBuilder.must( contAllBuilder );
             }
         }
 
-        private void processContainsSpecification( FilterBuilder filterBuilder,
+        private void processContainsSpecification( BoolQueryBuilder queryBuilder,
                                                    ContainsPredicate<?> spec,
                                                    Map<String, Object> variables )
         {
@@ -466,81 +435,81 @@ public interface ElasticSearchFinder
             else if( COMPLEX_TYPE_SUPPORTS.get( spec.value().getClass() ) != null )
             {
                 ComplexTypeSupport support = COMPLEX_TYPE_SUPPORTS.get( spec.value().getClass()
);
-                addFilter( support.contains( spec, variables ), filterBuilder );
+                queryBuilder.must( support.contains( spec, variables ) );
             }
             else
             {
                 Object value = resolveVariable( spec.value(), variables );
-                addFilter( termFilter( name, value ), filterBuilder );
+                queryBuilder.must( termQuery( name, value ) );
             }
         }
 
-        private void processMatchesSpecification( FilterBuilder filterBuilder,
+        private void processMatchesSpecification( BoolQueryBuilder queryBuilder,
                                                   MatchesPredicate spec,
                                                   Map<String, Object> variables )
         {
             LOGGER.trace( "Processing MatchesSpecification {}", spec );
             String name = spec.property().toString();
             String regexp = resolveVariable( spec.regexp(), variables ).toString();
-            addFilter( regexpFilter( name, regexp ), filterBuilder );
+            queryBuilder.must( regexpQuery( name, regexp ) );
         }
 
-        private void processPropertyNotNullSpecification( FilterBuilder filterBuilder,
+        private void processPropertyNotNullSpecification( BoolQueryBuilder queryBuilder,
                                                           PropertyNotNullPredicate<?>
spec )
         {
             LOGGER.trace( "Processing PropertyNotNullSpecification {}", spec );
-            addFilter( existsFilter( spec.property().toString() ), filterBuilder );
+            queryBuilder.must( existsQuery( spec.property().toString() ) );
         }
 
-        private void processPropertyNullSpecification( FilterBuilder filterBuilder,
+        private void processPropertyNullSpecification( BoolQueryBuilder queryBuilder,
                                                        PropertyNullPredicate<?> spec
)
         {
             LOGGER.trace( "Processing PropertyNullSpecification {}", spec );
-            addFilter( missingFilter( spec.property().toString() ), filterBuilder );
+            queryBuilder.mustNot( existsQuery( ( spec.property().toString() ) ) );
         }
 
-        private void processAssociationNotNullSpecification( FilterBuilder filterBuilder,
+        private void processAssociationNotNullSpecification( BoolQueryBuilder queryBuilder,
                                                              AssociationNotNullPredicate<?>
spec )
         {
             LOGGER.trace( "Processing AssociationNotNullSpecification {}", spec );
-            addFilter( existsFilter( spec.association().toString() + ".identity" ), filterBuilder
);
+            queryBuilder.must( existsQuery( spec.association().toString() + ".identity" )
);
         }
 
-        private void processAssociationNullSpecification( FilterBuilder filterBuilder,
+        private void processAssociationNullSpecification( BoolQueryBuilder queryBuilder,
                                                           AssociationNullPredicate<?>
spec )
         {
             LOGGER.trace( "Processing AssociationNullSpecification {}", spec );
-            addFilter( missingFilter( spec.association().toString() + ".identity" ), filterBuilder
);
+            queryBuilder.mustNot( existsQuery( ( spec.association().toString() + ".identity"
) ) );
         }
 
-        private void processManyAssociationContainsSpecification( FilterBuilder filterBuilder,
+        private void processManyAssociationContainsSpecification( BoolQueryBuilder queryBuilder,
                                                                   ManyAssociationContainsPredicate<?>
spec,
                                                                   Map<String, Object>
variables )
         {
             LOGGER.trace( "Processing ManyAssociationContainsSpecification {}", spec );
             String name = spec.manyAssociation().toString() + ".identity";
             Object value = resolveVariable( spec.value(), variables );
-            addFilter( termFilter( name, value ), filterBuilder );
+            queryBuilder.must( termQuery( name, value ) );
         }
 
-        private void processNamedAssociationContainsSpecification( FilterBuilder filterBuilder,
+        private void processNamedAssociationContainsSpecification( BoolQueryBuilder queryBuilder,
                                                                    NamedAssociationContainsPredicate<?>
spec,
                                                                    Map<String, Object>
variables )
         {
             LOGGER.trace( "Processing NamedAssociationContainsSpecification {}", spec );
             String name = spec.namedAssociation().toString() + ".identity";
             Object value = resolveVariable( spec.value(), variables );
-            addFilter( termFilter( name, value ), filterBuilder );
+            queryBuilder.must( termQuery( name, value ) );
         }
 
-        private void processNamedAssociationContainsNameSpecification( FilterBuilder filterBuilder,
+        private void processNamedAssociationContainsNameSpecification( BoolQueryBuilder queryBuilder,
                                                                        NamedAssociationContainsNamePredicate<?>
spec,
                                                                        Map<String, Object>
variables )
         {
             LOGGER.trace( "Processing NamedAssociationContainsNameSpecification {}", spec
);
             String name = spec.namedAssociation().toString() + "._named";
             Object value = resolveVariable( spec.name(), variables );
-            addFilter( termFilter( name, value ), filterBuilder );
+            queryBuilder.must( termQuery( name, value ) );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderSupport.java
index 80c1b1f..22ddd41 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderSupport.java
@@ -20,11 +20,11 @@
 package org.apache.zest.index.elasticsearch;
 
 import java.util.Map;
-import org.elasticsearch.index.query.FilterBuilder;
 import org.apache.zest.api.query.grammar.ComparisonPredicate;
 import org.apache.zest.api.query.grammar.ContainsAllPredicate;
 import org.apache.zest.api.query.grammar.ContainsPredicate;
 import org.apache.zest.api.query.grammar.Variable;
+import org.elasticsearch.index.query.QueryBuilder;
 
 
 /* package */ final class ElasticSearchFinderSupport
@@ -52,11 +52,11 @@ import org.apache.zest.api.query.grammar.Variable;
     /* package */ static interface ComplexTypeSupport
     {
 
-        FilterBuilder comparison( ComparisonPredicate<?> spec, Map<String, Object>
variables );
+        QueryBuilder comparison( ComparisonPredicate<?> spec, Map<String, Object>
variables );
 
-        FilterBuilder contains( ContainsPredicate<?> spec, Map<String, Object>
variables );
+        QueryBuilder contains( ContainsPredicate<?> spec, Map<String, Object>
variables );
 
-        FilterBuilder containsAll( ContainsAllPredicate<?> spec, Map<String, Object>
variables );
+        QueryBuilder containsAll( ContainsAllPredicate<?> spec, Map<String, Object>
variables );
 
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
index d8cdfdf..a49354e 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
@@ -20,7 +20,6 @@
 package org.apache.zest.index.elasticsearch.cluster;
 
 import org.elasticsearch.client.transport.TransportClient;
-import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.apache.zest.api.configuration.Configuration;
@@ -28,6 +27,8 @@ import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.index.elasticsearch.ElasticSearchClusterConfiguration;
 import org.apache.zest.index.elasticsearch.internal.AbstractElasticSearchSupport;
 
+import java.net.InetSocketAddress;
+
 public class ESClusterSupport
         extends AbstractElasticSearchSupport
 {
@@ -52,19 +53,19 @@ public class ESClusterSupport
         String pingTimeout = config.pingTimeout().get() == null ? "5s" : config.pingTimeout().get();
         String samplerInterval = config.samplerInterval().get() == null ? "5s" : config.samplerInterval().get();
 
-        Settings settings = ImmutableSettings.settingsBuilder().
+        Settings settings = Settings.settingsBuilder().
                 put( "cluster.name", clusterName ).
                 put( "client.transport.sniff", clusterSniff ).
                 put( "client.transport.ignore_cluster_name", ignoreClusterName ).
                 put( "client.transport.ping_timeout", pingTimeout ).
                 put( "client.transport.nodes_sampler_interval", samplerInterval ).
                 build();
-        TransportClient transportClient = new TransportClient( settings );
+        TransportClient transportClient = TransportClient.builder().settings(settings).build();
         for ( String node : nodes ) {
             String[] split = node.split( ":" );
             String host = split[0];
             int port = Integer.valueOf( split[1] );
-            transportClient.addTransportAddress( new InetSocketTransportAddress( host, port
) );
+            transportClient.addTransportAddress( new InetSocketTransportAddress( new InetSocketAddress(
host, port ) ) );
         }
 
         client = transportClient;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
index 91e1475..2072bc8 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
@@ -20,7 +20,6 @@
 package org.apache.zest.index.elasticsearch.filesystem;
 
 import java.io.File;
-import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
@@ -59,12 +58,12 @@ public class ESFilesystemSupport
         indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
 
         String identity = hasIdentity.identity().get();
-        Settings settings = ImmutableSettings.settingsBuilder().
-                put( "path.work", new File( fileConfig.temporaryDirectory(), identity ).getAbsolutePath()
).
+        Settings settings = Settings.settingsBuilder().
+                put( "path.work", new File( new File( fileConfig.temporaryDirectory(), identity
), "work" ).getAbsolutePath() ).
+                put( "path.home", new File( new File( fileConfig.temporaryDirectory(), identity
), "home" ).getAbsolutePath() ).
                 put( "path.logs", new File( fileConfig.logDirectory(), identity ).getAbsolutePath()
).
                 put( "path.data", new File( fileConfig.dataDirectory(), identity ).getAbsolutePath()
).
                 put( "path.conf", new File( fileConfig.configurationDirectory(), identity
).getAbsolutePath() ).
-                put( "gateway.type", "local" ).
                 put( "http.enabled", false ).
                 put( "index.cache.type", "weak" ).
                 put( "index.number_of_shards", 1 ).

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
index f0ed2df..53cde85 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
@@ -20,7 +20,7 @@
 package org.apache.zest.index.elasticsearch.internal;
 
 import org.elasticsearch.client.Client;
-import org.elasticsearch.common.settings.ImmutableSettings;
+import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.apache.zest.index.elasticsearch.ElasticSearchSupport;
 import org.slf4j.Logger;
@@ -56,7 +56,7 @@ public abstract class AbstractElasticSearchSupport
         if ( !client.admin().indices().prepareExists( index ).setIndices( index ).execute().actionGet().isExists()
) {
             // Create empty index
             LOGGER.info( "Will create '{}' index as it does not exists.", index );
-            ImmutableSettings.Builder indexSettings = ImmutableSettings.settingsBuilder().loadFromSource(
XContentFactory.jsonBuilder().
+            Settings.Builder indexSettings = Settings.settingsBuilder().loadFromSource( XContentFactory.jsonBuilder().
                     startObject().
                     startObject( "analysis" ).
                     startObject( "analyzer" ).

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/memory/ESMemorySupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/memory/ESMemorySupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/memory/ESMemorySupport.java
index badce2f..2239810 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/memory/ESMemorySupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/memory/ESMemorySupport.java
@@ -20,7 +20,6 @@
 package org.apache.zest.index.elasticsearch.memory;
 
 import java.io.File;
-import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
@@ -59,12 +58,12 @@ public class ESMemorySupport
         indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
 
         String identity = hasIdentity.identity().get();
-        Settings settings = ImmutableSettings.settingsBuilder().
-                put( "path.work", new File( fileConfig.temporaryDirectory(), identity ).getAbsolutePath()
).
+        Settings settings = Settings.settingsBuilder().
+                put( "path.work", new File( new File( fileConfig.temporaryDirectory(), identity
),  "work" ).getAbsolutePath() ).
+                put( "path.home", new File( new File( fileConfig.temporaryDirectory(), identity
), "home" ).getAbsolutePath() ).
                 put( "path.logs", new File( fileConfig.logDirectory(), identity ).getAbsolutePath()
).
                 put( "path.data", new File( fileConfig.dataDirectory(), identity ).getAbsolutePath()
).
                 put( "path.conf", new File( fileConfig.configurationDirectory(), identity
).getAbsolutePath() ).
-                put( "gateway.type", "none" ).
                 put( "http.enabled", false ).
                 put( "index.cache.type", "weak" ).
                 put( "index.store.type", "memory" ).

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e6133864/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index 3f6dda7..170527d 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -27,7 +27,7 @@ def commonsLangVersion = '3.4'
 def derbyVersion = '10.12.1.1'
 def dnsJavaVersion = '2.1.7'
 def ehcacheVersion = '2.10.2.2.21' // 3.x exists
-def elasticsearchVersion = '1.7.5' // 2.x exists
+def elasticsearchVersion = '2.4.0'
 def freemarkerVersion = '2.3.25-incubating'
 def geodeVersion = '1.0.0-incubating.M3'
 def groovyVersion = '2.4.7'


Mime
View raw message