You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2018/04/26 13:11:15 UTC

svn commit: r1830214 - in /jackrabbit/oak/branches/1.6/oak-lucene/src: main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/ test/java/org/apache/jackrabbit/oak/plugins/index/lucene/

Author: reschke
Date: Thu Apr 26 13:11:15 2018
New Revision: 1830214

URL: http://svn.apache.org/viewvc?rev=1830214&view=rev
Log:
OAK-7454: oak-lucene: fix broken line ends in repo (in 1.6)

Modified:
    jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java
    jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/FulltextQueryTermsProvider.java
    jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/IndexFieldProvider.java
    jackrabbit/oak/branches/1.6/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactoryTest.java

Modified: jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java?rev=1830214&r1=1830213&r2=1830214&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java (original)
+++ jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java Thu Apr 26 13:11:15 2018
@@ -1,253 +1,253 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.lucene;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.References;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.jackrabbit.oak.plugins.index.lucene.spi.FulltextQueryTermsProvider;
-import org.apache.jackrabbit.oak.plugins.index.lucene.spi.IndexFieldProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.util.PerfLogger;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@SuppressWarnings("UnusedDeclaration")
-@Component
-@Service(value = IndexAugmentorFactory.class)
-@References({
-        @Reference(name = "IndexFieldProvider",
-                policy = ReferencePolicy.DYNAMIC,
-                cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
-                referenceInterface = IndexFieldProvider.class),
-        @Reference(name = "FulltextQueryTermsProvider",
-                policy = ReferencePolicy.DYNAMIC,
-                cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
-                referenceInterface = FulltextQueryTermsProvider.class)
-})
-public class IndexAugmentorFactory {
-
-    private static final PerfLogger PERFLOG = new PerfLogger(
-            LoggerFactory.getLogger(IndexAugmentorFactory.class.getName() + ".perf"));
-
-    private final Set<IndexFieldProvider> indexFieldProviders;
-    private final Set<FulltextQueryTermsProvider> fulltextQueryTermsProviders;
-
-    private volatile Map<String, CompositeIndexFieldProvider> indexFieldProviderMap;
-    private volatile Map<String, CompositeFulltextQueryTermsProvider> fulltextQueryTermsProviderMap;
-
-    public IndexAugmentorFactory() {
-        indexFieldProviders = Sets.newIdentityHashSet();
-        fulltextQueryTermsProviders = Sets.newIdentityHashSet();
-
-        resetState();
-    }
-
-    @Deactivate
-    private synchronized void deactivate() {
-        resetState();
-    }
-
-    @Nonnull
-    public IndexFieldProvider getIndexFieldProvider(String nodeType) {
-        IndexFieldProvider provider = indexFieldProviderMap.get(nodeType);
-        return (provider != null) ? provider : IndexFieldProvider.DEFAULT;
-    }
-
-    @Nonnull
-    public FulltextQueryTermsProvider getFulltextQueryTermsProvider(String nodeType) {
-        FulltextQueryTermsProvider provider = fulltextQueryTermsProviderMap.get(nodeType);
-        return (provider != null) ? provider : FulltextQueryTermsProvider.DEFAULT;
-    }
-
-    synchronized void bindIndexFieldProvider(IndexFieldProvider indexFieldProvider) {
-        indexFieldProviders.add(indexFieldProvider);
-        refreshIndexFieldProviders();
-    }
-
-    synchronized void unbindIndexFieldProvider(IndexFieldProvider indexFieldProvider) {
-        indexFieldProviders.remove(indexFieldProvider);
-        refreshIndexFieldProviders();
-    }
-
-    synchronized void bindFulltextQueryTermsProvider(FulltextQueryTermsProvider fulltextQueryTermsProvider) {
-        fulltextQueryTermsProviders.add(fulltextQueryTermsProvider);
-        refreshFulltextQueryTermsProviders();
-    }
-
-    synchronized void unbindFulltextQueryTermsProvider(FulltextQueryTermsProvider fulltextQueryTermsProvider) {
-        fulltextQueryTermsProviders.remove(fulltextQueryTermsProvider);
-        refreshFulltextQueryTermsProviders();
-    }
-
-    private void refreshIndexFieldProviders() {
-        ListMultimap<String, IndexFieldProvider> providerMultimap =
-                LinkedListMultimap.create();
-        for (IndexFieldProvider provider : indexFieldProviders) {
-            Set<String> supportedNodeTypes = provider.getSupportedTypes();
-            for (String nodeType : supportedNodeTypes) {
-                providerMultimap.put(nodeType, provider);
-            }
-        }
-
-        Map<String, CompositeIndexFieldProvider> providerMap = Maps.newHashMap();
-        for (String nodeType : providerMultimap.keySet()) {
-            List<IndexFieldProvider> providers = providerMultimap.get(nodeType);
-            CompositeIndexFieldProvider compositeIndexFieldProvider =
-                    new CompositeIndexFieldProvider(nodeType, providers);
-            providerMap.put(nodeType, compositeIndexFieldProvider);
-        }
-
-        indexFieldProviderMap = ImmutableMap.copyOf(providerMap);
-    }
-
-    private void refreshFulltextQueryTermsProviders() {
-        ListMultimap<String, FulltextQueryTermsProvider> providerMultimap =
-                LinkedListMultimap.create();
-        for (FulltextQueryTermsProvider provider : fulltextQueryTermsProviders) {
-            Set<String> supportedNodeTypes = provider.getSupportedTypes();
-            for (String nodeType : supportedNodeTypes) {
-                providerMultimap.put(nodeType, provider);
-            }
-        }
-
-        Map<String, CompositeFulltextQueryTermsProvider> providerMap = Maps.newHashMap();
-        for (String nodeType : providerMultimap.keySet()) {
-            List<FulltextQueryTermsProvider> providers = providerMultimap.get(nodeType);
-            CompositeFulltextQueryTermsProvider compositeFulltextQueryTermsProvider =
-                    new CompositeFulltextQueryTermsProvider(nodeType, providers);
-            providerMap.put(nodeType, compositeFulltextQueryTermsProvider);
-        }
-
-        fulltextQueryTermsProviderMap = ImmutableMap.copyOf(providerMap);
-    }
-
-    private void resetState() {
-        indexFieldProviders.clear();
-        fulltextQueryTermsProviders.clear();
-
-        indexFieldProviderMap = Collections.EMPTY_MAP;
-        fulltextQueryTermsProviderMap = Collections.EMPTY_MAP;
-    }
-
-    boolean isStateEmpty() {
-        return indexFieldProviders.size() == 0 &&
-                indexFieldProviderMap.size() == 0 &&
-                fulltextQueryTermsProviders.size() == 0 &&
-                fulltextQueryTermsProviderMap.size() == 0;
-    }
-
-    class CompositeIndexFieldProvider implements IndexFieldProvider {
-
-        private final String nodeType;
-        private final List<IndexFieldProvider> providers;
-
-        CompositeIndexFieldProvider(String nodeType, List<IndexFieldProvider> providers) {
-            this.nodeType = nodeType;
-            this.providers = ImmutableList.copyOf(providers);
-        }
-
-        @Nonnull
-        @Override
-        public List<Field> getAugmentedFields(final String path,
-                                              final NodeState document, final NodeState indexDefinition) {
-            List<Field> fields = Lists.newArrayList();
-            for (IndexFieldProvider indexFieldProvider : providers) {
-                final long start = PERFLOG.start();
-                Iterable<Field> providedFields = indexFieldProvider.getAugmentedFields(path, document, indexDefinition);
-                PERFLOG.end(start, 1, "indexFieldProvider: {}, path: {}, doc: {}, indexDef: {}",
-                        indexFieldProvider, path, document, indexDefinition);
-                for (Field f : providedFields) {
-                    fields.add(f);
-                }
-            }
-            return fields;
-        }
-
-        @Nonnull
-        @Override
-        public Set<String> getSupportedTypes() {
-            return Collections.singleton(nodeType);
-        }
-    }
-
-    class CompositeFulltextQueryTermsProvider implements FulltextQueryTermsProvider {
-
-        private final String nodeType;
-        private final List<FulltextQueryTermsProvider> providers;
-
-        CompositeFulltextQueryTermsProvider(String nodeType, List<FulltextQueryTermsProvider> providers) {
-            this.nodeType = nodeType;
-            this.providers = ImmutableList.copyOf(providers);
-        }
-
-        @Override
-        public Query getQueryTerm(final String text, final Analyzer analyzer, NodeState indexDefinition) {
-            List<Query> subQueries = Lists.newArrayList();
-            for (FulltextQueryTermsProvider fulltextQueryTermsProvider : providers) {
-                final long start = PERFLOG.start();
-                Query subQuery = fulltextQueryTermsProvider.getQueryTerm(text, analyzer, indexDefinition);
-                PERFLOG.end(start, 1, "fulltextQueryTermsProvider: {}, text: {}", fulltextQueryTermsProvider, text);
-                if (subQuery != null) {
-                    subQueries.add(subQuery);
-                }
-            }
-
-            Query ret;
-            if (subQueries.size() == 0) {
-                ret = null;
-            } else if (subQueries.size() == 1) {
-                ret = subQueries.get(0);
-            } else {
-                BooleanQuery query = new BooleanQuery();
-                for ( Query subQuery : subQueries ) {
-                    query.add(subQuery, BooleanClause.Occur.SHOULD);
-                }
-                ret = query;
-            }
-
-            return ret;
-        }
-
-        @Nonnull
-        @Override
-        public Set<String> getSupportedTypes() {
-            return Collections.singleton(nodeType);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.lucene;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.References;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.oak.plugins.index.lucene.spi.FulltextQueryTermsProvider;
+import org.apache.jackrabbit.oak.plugins.index.lucene.spi.IndexFieldProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.util.PerfLogger;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@SuppressWarnings("UnusedDeclaration")
+@Component
+@Service(value = IndexAugmentorFactory.class)
+@References({
+        @Reference(name = "IndexFieldProvider",
+                policy = ReferencePolicy.DYNAMIC,
+                cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+                referenceInterface = IndexFieldProvider.class),
+        @Reference(name = "FulltextQueryTermsProvider",
+                policy = ReferencePolicy.DYNAMIC,
+                cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+                referenceInterface = FulltextQueryTermsProvider.class)
+})
+public class IndexAugmentorFactory {
+
+    private static final PerfLogger PERFLOG = new PerfLogger(
+            LoggerFactory.getLogger(IndexAugmentorFactory.class.getName() + ".perf"));
+
+    private final Set<IndexFieldProvider> indexFieldProviders;
+    private final Set<FulltextQueryTermsProvider> fulltextQueryTermsProviders;
+
+    private volatile Map<String, CompositeIndexFieldProvider> indexFieldProviderMap;
+    private volatile Map<String, CompositeFulltextQueryTermsProvider> fulltextQueryTermsProviderMap;
+
+    public IndexAugmentorFactory() {
+        indexFieldProviders = Sets.newIdentityHashSet();
+        fulltextQueryTermsProviders = Sets.newIdentityHashSet();
+
+        resetState();
+    }
+
+    @Deactivate
+    private synchronized void deactivate() {
+        resetState();
+    }
+
+    @Nonnull
+    public IndexFieldProvider getIndexFieldProvider(String nodeType) {
+        IndexFieldProvider provider = indexFieldProviderMap.get(nodeType);
+        return (provider != null) ? provider : IndexFieldProvider.DEFAULT;
+    }
+
+    @Nonnull
+    public FulltextQueryTermsProvider getFulltextQueryTermsProvider(String nodeType) {
+        FulltextQueryTermsProvider provider = fulltextQueryTermsProviderMap.get(nodeType);
+        return (provider != null) ? provider : FulltextQueryTermsProvider.DEFAULT;
+    }
+
+    synchronized void bindIndexFieldProvider(IndexFieldProvider indexFieldProvider) {
+        indexFieldProviders.add(indexFieldProvider);
+        refreshIndexFieldProviders();
+    }
+
+    synchronized void unbindIndexFieldProvider(IndexFieldProvider indexFieldProvider) {
+        indexFieldProviders.remove(indexFieldProvider);
+        refreshIndexFieldProviders();
+    }
+
+    synchronized void bindFulltextQueryTermsProvider(FulltextQueryTermsProvider fulltextQueryTermsProvider) {
+        fulltextQueryTermsProviders.add(fulltextQueryTermsProvider);
+        refreshFulltextQueryTermsProviders();
+    }
+
+    synchronized void unbindFulltextQueryTermsProvider(FulltextQueryTermsProvider fulltextQueryTermsProvider) {
+        fulltextQueryTermsProviders.remove(fulltextQueryTermsProvider);
+        refreshFulltextQueryTermsProviders();
+    }
+
+    private void refreshIndexFieldProviders() {
+        ListMultimap<String, IndexFieldProvider> providerMultimap =
+                LinkedListMultimap.create();
+        for (IndexFieldProvider provider : indexFieldProviders) {
+            Set<String> supportedNodeTypes = provider.getSupportedTypes();
+            for (String nodeType : supportedNodeTypes) {
+                providerMultimap.put(nodeType, provider);
+            }
+        }
+
+        Map<String, CompositeIndexFieldProvider> providerMap = Maps.newHashMap();
+        for (String nodeType : providerMultimap.keySet()) {
+            List<IndexFieldProvider> providers = providerMultimap.get(nodeType);
+            CompositeIndexFieldProvider compositeIndexFieldProvider =
+                    new CompositeIndexFieldProvider(nodeType, providers);
+            providerMap.put(nodeType, compositeIndexFieldProvider);
+        }
+
+        indexFieldProviderMap = ImmutableMap.copyOf(providerMap);
+    }
+
+    private void refreshFulltextQueryTermsProviders() {
+        ListMultimap<String, FulltextQueryTermsProvider> providerMultimap =
+                LinkedListMultimap.create();
+        for (FulltextQueryTermsProvider provider : fulltextQueryTermsProviders) {
+            Set<String> supportedNodeTypes = provider.getSupportedTypes();
+            for (String nodeType : supportedNodeTypes) {
+                providerMultimap.put(nodeType, provider);
+            }
+        }
+
+        Map<String, CompositeFulltextQueryTermsProvider> providerMap = Maps.newHashMap();
+        for (String nodeType : providerMultimap.keySet()) {
+            List<FulltextQueryTermsProvider> providers = providerMultimap.get(nodeType);
+            CompositeFulltextQueryTermsProvider compositeFulltextQueryTermsProvider =
+                    new CompositeFulltextQueryTermsProvider(nodeType, providers);
+            providerMap.put(nodeType, compositeFulltextQueryTermsProvider);
+        }
+
+        fulltextQueryTermsProviderMap = ImmutableMap.copyOf(providerMap);
+    }
+
+    private void resetState() {
+        indexFieldProviders.clear();
+        fulltextQueryTermsProviders.clear();
+
+        indexFieldProviderMap = Collections.EMPTY_MAP;
+        fulltextQueryTermsProviderMap = Collections.EMPTY_MAP;
+    }
+
+    boolean isStateEmpty() {
+        return indexFieldProviders.size() == 0 &&
+                indexFieldProviderMap.size() == 0 &&
+                fulltextQueryTermsProviders.size() == 0 &&
+                fulltextQueryTermsProviderMap.size() == 0;
+    }
+
+    class CompositeIndexFieldProvider implements IndexFieldProvider {
+
+        private final String nodeType;
+        private final List<IndexFieldProvider> providers;
+
+        CompositeIndexFieldProvider(String nodeType, List<IndexFieldProvider> providers) {
+            this.nodeType = nodeType;
+            this.providers = ImmutableList.copyOf(providers);
+        }
+
+        @Nonnull
+        @Override
+        public List<Field> getAugmentedFields(final String path,
+                                              final NodeState document, final NodeState indexDefinition) {
+            List<Field> fields = Lists.newArrayList();
+            for (IndexFieldProvider indexFieldProvider : providers) {
+                final long start = PERFLOG.start();
+                Iterable<Field> providedFields = indexFieldProvider.getAugmentedFields(path, document, indexDefinition);
+                PERFLOG.end(start, 1, "indexFieldProvider: {}, path: {}, doc: {}, indexDef: {}",
+                        indexFieldProvider, path, document, indexDefinition);
+                for (Field f : providedFields) {
+                    fields.add(f);
+                }
+            }
+            return fields;
+        }
+
+        @Nonnull
+        @Override
+        public Set<String> getSupportedTypes() {
+            return Collections.singleton(nodeType);
+        }
+    }
+
+    class CompositeFulltextQueryTermsProvider implements FulltextQueryTermsProvider {
+
+        private final String nodeType;
+        private final List<FulltextQueryTermsProvider> providers;
+
+        CompositeFulltextQueryTermsProvider(String nodeType, List<FulltextQueryTermsProvider> providers) {
+            this.nodeType = nodeType;
+            this.providers = ImmutableList.copyOf(providers);
+        }
+
+        @Override
+        public Query getQueryTerm(final String text, final Analyzer analyzer, NodeState indexDefinition) {
+            List<Query> subQueries = Lists.newArrayList();
+            for (FulltextQueryTermsProvider fulltextQueryTermsProvider : providers) {
+                final long start = PERFLOG.start();
+                Query subQuery = fulltextQueryTermsProvider.getQueryTerm(text, analyzer, indexDefinition);
+                PERFLOG.end(start, 1, "fulltextQueryTermsProvider: {}, text: {}", fulltextQueryTermsProvider, text);
+                if (subQuery != null) {
+                    subQueries.add(subQuery);
+                }
+            }
+
+            Query ret;
+            if (subQueries.size() == 0) {
+                ret = null;
+            } else if (subQueries.size() == 1) {
+                ret = subQueries.get(0);
+            } else {
+                BooleanQuery query = new BooleanQuery();
+                for ( Query subQuery : subQueries ) {
+                    query.add(subQuery, BooleanClause.Occur.SHOULD);
+                }
+                ret = query;
+            }
+
+            return ret;
+        }
+
+        @Nonnull
+        @Override
+        public Set<String> getSupportedTypes() {
+            return Collections.singleton(nodeType);
+        }
+    }
+}

Modified: jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/FulltextQueryTermsProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/FulltextQueryTermsProvider.java?rev=1830214&r1=1830213&r2=1830214&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/FulltextQueryTermsProvider.java (original)
+++ jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/FulltextQueryTermsProvider.java Thu Apr 26 13:11:15 2018
@@ -1,66 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.lucene.spi;
-
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.search.Query;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * Implementations of this interface would get callbacks while forming lucene full text queries.
- */
-public interface FulltextQueryTermsProvider {
-    /**
-     * Implementation which doesn't do anything useful... yet, abides with the contract.
-     */
-    FulltextQueryTermsProvider DEFAULT = new FulltextQueryTermsProvider() {
-        @Override
-        public Query getQueryTerm(String text, Analyzer analyzer, NodeState indexDefinition) {
-            return null;
-        }
-
-        @Override
-        public Set<String> getSupportedTypes() {
-            return Collections.EMPTY_SET;
-        }
-    };
-    /**
-     * This method would get called while forming full text clause for full text clause not constrained on a particular
-     * field.
-     * @param text full text term
-     * @param analyzer {@link Analyzer} being used while forming the query. Can be used to analyze text consistently.
-     * @param indexDefinition {@link NodeState} of index definition
-     * @return {@link Query} object to be OR'ed with query being prepared. {@code null}, if nothing is to be added.
-     */
-    @CheckForNull
-    Query getQueryTerm(String text, Analyzer analyzer, NodeState indexDefinition);
-
-    /**
-     * This method is used to find which node types are supported by the implementation. Based, on the index
-     * definition being used to query the document, only those implementations would get callback to
-     * {@link FulltextQueryTermsProvider#getQueryTerm} which declare a matching node type. Note, node types are
-     * exact matches and do not support inheritance.
-     * @return {@link Set} of types supported by the implementation
-     */
-    @Nonnull
-    Set<String> getSupportedTypes();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.lucene.spi;
+
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.search.Query;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * Implementations of this interface would get callbacks while forming lucene full text queries.
+ */
+public interface FulltextQueryTermsProvider {
+    /**
+     * Implementation which doesn't do anything useful... yet, abides with the contract.
+     */
+    FulltextQueryTermsProvider DEFAULT = new FulltextQueryTermsProvider() {
+        @Override
+        public Query getQueryTerm(String text, Analyzer analyzer, NodeState indexDefinition) {
+            return null;
+        }
+
+        @Override
+        public Set<String> getSupportedTypes() {
+            return Collections.EMPTY_SET;
+        }
+    };
+    /**
+     * This method would get called while forming full text clause for full text clause not constrained on a particular
+     * field.
+     * @param text full text term
+     * @param analyzer {@link Analyzer} being used while forming the query. Can be used to analyze text consistently.
+     * @param indexDefinition {@link NodeState} of index definition
+     * @return {@link Query} object to be OR'ed with query being prepared. {@code null}, if nothing is to be added.
+     */
+    @CheckForNull
+    Query getQueryTerm(String text, Analyzer analyzer, NodeState indexDefinition);
+
+    /**
+     * This method is used to find which node types are supported by the implementation. Based, on the index
+     * definition being used to query the document, only those implementations would get callback to
+     * {@link FulltextQueryTermsProvider#getQueryTerm} which declare a matching node type. Note, node types are
+     * exact matches and do not support inheritance.
+     * @return {@link Set} of types supported by the implementation
+     */
+    @Nonnull
+    Set<String> getSupportedTypes();
+}

Modified: jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/IndexFieldProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/IndexFieldProvider.java?rev=1830214&r1=1830213&r2=1830214&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/IndexFieldProvider.java (original)
+++ jackrabbit/oak/branches/1.6/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/spi/IndexFieldProvider.java Thu Apr 26 13:11:15 2018
@@ -1,66 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.lucene.spi;
-
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.lucene.document.Field;
-
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * Implementations of this interface would get callbacks while indexing documents. It's the responsibility
- * of the implementation to exit as early as possible if it doesn't care about the document being indexed.
- */
-public interface IndexFieldProvider {
-    /**
-     * Implementation which doesn't do anything useful... yet, abides with the contract.
-     */
-    IndexFieldProvider DEFAULT = new IndexFieldProvider() {
-        @Override
-        public Iterable<Field> getAugmentedFields(String path, NodeState document, NodeState indexDefinition) {
-            return Collections.EMPTY_LIST;
-        }
-
-        @Override
-        public Set<String> getSupportedTypes() {
-            return Collections.EMPTY_SET;
-        }
-    };
-
-    /**
-     * This method would get called while indexing a document.
-     *
-     * @param path path of the document being indexed
-     * @param document {@link NodeState} of the document being indexed
-     * @param indexDefinition {@link NodeState} of index definition
-     * @return {@link Iterable} of fields that are to be added to {@link org.apache.lucene.document.Document} being prepared
-     */
-    @Nonnull
-    Iterable<Field> getAugmentedFields(String path, NodeState document, NodeState indexDefinition);
-
-    /**
-     * This method is used to find which node types are supported by the implementation. Based, on the index
-     * definition being used to index the document, only those implementations would get callback to
-     * {@link IndexFieldProvider#getAugmentedFields} which declare a matching node type. Note, node types are
-     * exact matches and do not support inheritance.
-     * @return {@link Set} of types supported by the implementation
-     */
-    @Nonnull
-    Set<String> getSupportedTypes();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.lucene.spi;
+
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.lucene.document.Field;
+
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * Implementations of this interface would get callbacks while indexing documents. It's the responsibility
+ * of the implementation to exit as early as possible if it doesn't care about the document being indexed.
+ */
+public interface IndexFieldProvider {
+    /**
+     * Implementation which doesn't do anything useful... yet, abides with the contract.
+     */
+    IndexFieldProvider DEFAULT = new IndexFieldProvider() {
+        @Override
+        public Iterable<Field> getAugmentedFields(String path, NodeState document, NodeState indexDefinition) {
+            return Collections.EMPTY_LIST;
+        }
+
+        @Override
+        public Set<String> getSupportedTypes() {
+            return Collections.EMPTY_SET;
+        }
+    };
+
+    /**
+     * This method would get called while indexing a document.
+     *
+     * @param path path of the document being indexed
+     * @param document {@link NodeState} of the document being indexed
+     * @param indexDefinition {@link NodeState} of index definition
+     * @return {@link Iterable} of fields that are to be added to {@link org.apache.lucene.document.Document} being prepared
+     */
+    @Nonnull
+    Iterable<Field> getAugmentedFields(String path, NodeState document, NodeState indexDefinition);
+
+    /**
+     * This method is used to find which node types are supported by the implementation. Based, on the index
+     * definition being used to index the document, only those implementations would get callback to
+     * {@link IndexFieldProvider#getAugmentedFields} which declare a matching node type. Note, node types are
+     * exact matches and do not support inheritance.
+     * @return {@link Set} of types supported by the implementation
+     */
+    @Nonnull
+    Set<String> getSupportedTypes();
+}

Modified: jackrabbit/oak/branches/1.6/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactoryTest.java?rev=1830214&r1=1830213&r2=1830214&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactoryTest.java (original)
+++ jackrabbit/oak/branches/1.6/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactoryTest.java Thu Apr 26 13:11:15 2018
@@ -1,214 +1,214 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.jackrabbit.oak.plugins.index.lucene;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import org.apache.jackrabbit.oak.plugins.index.lucene.spi.FulltextQueryTermsProvider;
-import org.apache.jackrabbit.oak.plugins.index.lucene.spi.IndexFieldProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.sling.testing.mock.osgi.MockOsgi;
-import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
-import org.hamcrest.CoreMatchers;
-import org.junit.Rule;
-import org.junit.Test;
-
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import static org.apache.lucene.search.BooleanClause.Occur.SHOULD;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public class IndexAugmentorFactoryTest {
-    private IndexAugmentorFactory indexAugmentorFactory = new IndexAugmentorFactory();
-
-    @Rule
-    public final OsgiContext context = new OsgiContext();
-
-    @Test
-    public void compositeIndexProvider()
-    {
-        final String typeA = "type:A";
-        final String typeB = "type:B";
-        final String typeC = "type:C";
-        final String typeD = "type:D";
-
-        context.registerInjectActivateService(indexAugmentorFactory);
-
-        new IdentifiableIndexFiledProvider("1", Sets.newHashSet(typeA, typeB));
-        new IdentifiableIndexFiledProvider("2", Sets.newHashSet(typeC));
-        new IdentifiableIndexFiledProvider("3", Sets.newHashSet(typeA, typeB));
-
-        //register an instance which would be unregistered before validation
-        IndexFieldProvider unreg = new IdentifiableIndexFiledProvider("4", Sets.newHashSet(typeD));
-        indexAugmentorFactory.unbindIndexFieldProvider(unreg);
-
-        validateComposedFields(typeA, "1", "3");
-        validateComposedFields(typeC, "2");
-        validateComposedFields(typeD);
-
-        MockOsgi.deactivate(indexAugmentorFactory, context.bundleContext(), Collections.EMPTY_MAP);
-
-        validateDeactivatedService();
-    }
-
-    @Test
-    public void compositeQueryTermsProvider()
-    {
-        final String typeA = "type:A";
-        final String typeB = "type:B";
-        final String typeC = "type:C";
-        final String typeD = "type:D";
-        final String typeE = "type:E";
-
-        context.registerInjectActivateService(indexAugmentorFactory);
-
-        new IdentifiableQueryTermsProvider("1", Sets.newHashSet(typeA, typeB));
-        new IdentifiableQueryTermsProvider("2", Sets.newHashSet(typeC));
-        new IdentifiableQueryTermsProvider("3", Sets.newHashSet(typeA, typeB));
-        new IdentifiableQueryTermsProvider(null, Sets.newHashSet(typeE));
-
-        //register an instance which would be unregistered before validation
-        FulltextQueryTermsProvider unreg = new IdentifiableQueryTermsProvider("4", Sets.newHashSet(typeD));
-        indexAugmentorFactory.unbindFulltextQueryTermsProvider(unreg);
-
-        validateComposedQueryTerms(typeA, "1", "3");
-        validateComposedQueryTerms(typeC, "2");
-        validateComposedQueryTerms(typeD);
-        validateComposedQueryTerms(typeE);
-
-        MockOsgi.deactivate(indexAugmentorFactory, context.bundleContext(), Collections.EMPTY_MAP);
-
-        validateDeactivatedService();
-    }
-
-    void validateComposedFields(String type, String ... expected) {
-        IndexFieldProvider compositeIndexProvider = indexAugmentorFactory.getIndexFieldProvider(type);
-
-        if (expected.length > 0) {
-            assertTrue("Composed index field provider doesn't declare correct supported type",
-                    compositeIndexProvider.getSupportedTypes().contains(type));
-        }
-
-        Iterable<Field> fields = compositeIndexProvider.getAugmentedFields(null, null, null);
-        Set<String> ids = Sets.newHashSet();
-        for (Field f : fields) {
-            ids.add(f.stringValue());
-        }
-
-        assertEquals(expected.length, Iterables.size(ids));
-        assertThat(ids, CoreMatchers.hasItems(expected));
-    }
-
-    void validateComposedQueryTerms(String type, String ... expected) {
-        FulltextQueryTermsProvider compositeQueryTermsProvider = indexAugmentorFactory.getFulltextQueryTermsProvider(type);
-
-        if (expected.length > 0) {
-            assertTrue("Composed query terms provider doesn't declare correct supported type",
-                    compositeQueryTermsProvider.getSupportedTypes().contains(type));
-        }
-
-        Query q = compositeQueryTermsProvider.getQueryTerm(null, null, null);
-        if (q == null) {
-            assertEquals("No query terms generated for " + type + ".", 0, expected.length);
-        } else {
-            Set<String> ids = Sets.newHashSet();
-            if (q instanceof BooleanQuery) {
-                BooleanQuery query = (BooleanQuery) q;
-                List<BooleanClause> clauses = query.clauses();
-                for (BooleanClause clause : clauses) {
-                    assertEquals(SHOULD, clause.getOccur());
-
-                    Query subQuery = clause.getQuery();
-                    String subQueryStr = subQuery.toString();
-                    ids.add(subQueryStr.substring(0, subQueryStr.indexOf(":1")));
-                }
-            } else {
-                String subQueryStr = q.toString();
-                ids.add(subQueryStr.substring(0, subQueryStr.indexOf(":1")));
-            }
-
-            assertEquals(expected.length, Iterables.size(ids));
-            assertThat(ids, CoreMatchers.hasItems(expected));
-        }
-    }
-
-    private void validateDeactivatedService() {
-        assertTrue("All data structures must be empty after deactivate", indexAugmentorFactory.isStateEmpty());
-    }
-
-    class IdentifiableIndexFiledProvider implements IndexFieldProvider {
-        private final Field id;
-        private final Set<String> nodeTypes;
-
-        IdentifiableIndexFiledProvider(String id, Set<String> nodeTypes) {
-            this.id = new StringField("id", id, Field.Store.NO);
-            this.nodeTypes = nodeTypes;
-            context.registerService(IndexFieldProvider.class, this);
-        }
-
-        @Nonnull
-        @Override
-        public Iterable<Field> getAugmentedFields(String path, NodeState document, NodeState indexDefinition) {
-            return Lists.newArrayList(id);
-        }
-
-        @Nonnull
-        @Override
-        public Set<String> getSupportedTypes() {
-            return nodeTypes;
-        }
-    }
-
-    class IdentifiableQueryTermsProvider implements FulltextQueryTermsProvider {
-        private final Query id;
-        private final Set<String> nodeTypes;
-
-        IdentifiableQueryTermsProvider(String id, Set<String> nodeTypes) {
-            this.id = (id == null)?null:new TermQuery(new Term(id, "1"));
-            this.nodeTypes = nodeTypes;
-            context.registerService(FulltextQueryTermsProvider.class, this);
-        }
-
-        @Override
-        public Query getQueryTerm(String text, Analyzer analyzer, NodeState indexDefinition) {
-            return id;
-        }
-
-        @Nonnull
-        @Override
-        public Set<String> getSupportedTypes() {
-            return nodeTypes;
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.index.lucene;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.apache.jackrabbit.oak.plugins.index.lucene.spi.FulltextQueryTermsProvider;
+import org.apache.jackrabbit.oak.plugins.index.lucene.spi.IndexFieldProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.sling.testing.mock.osgi.MockOsgi;
+import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
+import org.hamcrest.CoreMatchers;
+import org.junit.Rule;
+import org.junit.Test;
+
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import static org.apache.lucene.search.BooleanClause.Occur.SHOULD;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class IndexAugmentorFactoryTest {
+    private IndexAugmentorFactory indexAugmentorFactory = new IndexAugmentorFactory();
+
+    @Rule
+    public final OsgiContext context = new OsgiContext();
+
+    @Test
+    public void compositeIndexProvider()
+    {
+        final String typeA = "type:A";
+        final String typeB = "type:B";
+        final String typeC = "type:C";
+        final String typeD = "type:D";
+
+        context.registerInjectActivateService(indexAugmentorFactory);
+
+        new IdentifiableIndexFiledProvider("1", Sets.newHashSet(typeA, typeB));
+        new IdentifiableIndexFiledProvider("2", Sets.newHashSet(typeC));
+        new IdentifiableIndexFiledProvider("3", Sets.newHashSet(typeA, typeB));
+
+        //register an instance which would be unregistered before validation
+        IndexFieldProvider unreg = new IdentifiableIndexFiledProvider("4", Sets.newHashSet(typeD));
+        indexAugmentorFactory.unbindIndexFieldProvider(unreg);
+
+        validateComposedFields(typeA, "1", "3");
+        validateComposedFields(typeC, "2");
+        validateComposedFields(typeD);
+
+        MockOsgi.deactivate(indexAugmentorFactory, context.bundleContext(), Collections.EMPTY_MAP);
+
+        validateDeactivatedService();
+    }
+
+    @Test
+    public void compositeQueryTermsProvider()
+    {
+        final String typeA = "type:A";
+        final String typeB = "type:B";
+        final String typeC = "type:C";
+        final String typeD = "type:D";
+        final String typeE = "type:E";
+
+        context.registerInjectActivateService(indexAugmentorFactory);
+
+        new IdentifiableQueryTermsProvider("1", Sets.newHashSet(typeA, typeB));
+        new IdentifiableQueryTermsProvider("2", Sets.newHashSet(typeC));
+        new IdentifiableQueryTermsProvider("3", Sets.newHashSet(typeA, typeB));
+        new IdentifiableQueryTermsProvider(null, Sets.newHashSet(typeE));
+
+        //register an instance which would be unregistered before validation
+        FulltextQueryTermsProvider unreg = new IdentifiableQueryTermsProvider("4", Sets.newHashSet(typeD));
+        indexAugmentorFactory.unbindFulltextQueryTermsProvider(unreg);
+
+        validateComposedQueryTerms(typeA, "1", "3");
+        validateComposedQueryTerms(typeC, "2");
+        validateComposedQueryTerms(typeD);
+        validateComposedQueryTerms(typeE);
+
+        MockOsgi.deactivate(indexAugmentorFactory, context.bundleContext(), Collections.EMPTY_MAP);
+
+        validateDeactivatedService();
+    }
+
+    void validateComposedFields(String type, String ... expected) {
+        IndexFieldProvider compositeIndexProvider = indexAugmentorFactory.getIndexFieldProvider(type);
+
+        if (expected.length > 0) {
+            assertTrue("Composed index field provider doesn't declare correct supported type",
+                    compositeIndexProvider.getSupportedTypes().contains(type));
+        }
+
+        Iterable<Field> fields = compositeIndexProvider.getAugmentedFields(null, null, null);
+        Set<String> ids = Sets.newHashSet();
+        for (Field f : fields) {
+            ids.add(f.stringValue());
+        }
+
+        assertEquals(expected.length, Iterables.size(ids));
+        assertThat(ids, CoreMatchers.hasItems(expected));
+    }
+
+    void validateComposedQueryTerms(String type, String ... expected) {
+        FulltextQueryTermsProvider compositeQueryTermsProvider = indexAugmentorFactory.getFulltextQueryTermsProvider(type);
+
+        if (expected.length > 0) {
+            assertTrue("Composed query terms provider doesn't declare correct supported type",
+                    compositeQueryTermsProvider.getSupportedTypes().contains(type));
+        }
+
+        Query q = compositeQueryTermsProvider.getQueryTerm(null, null, null);
+        if (q == null) {
+            assertEquals("No query terms generated for " + type + ".", 0, expected.length);
+        } else {
+            Set<String> ids = Sets.newHashSet();
+            if (q instanceof BooleanQuery) {
+                BooleanQuery query = (BooleanQuery) q;
+                List<BooleanClause> clauses = query.clauses();
+                for (BooleanClause clause : clauses) {
+                    assertEquals(SHOULD, clause.getOccur());
+
+                    Query subQuery = clause.getQuery();
+                    String subQueryStr = subQuery.toString();
+                    ids.add(subQueryStr.substring(0, subQueryStr.indexOf(":1")));
+                }
+            } else {
+                String subQueryStr = q.toString();
+                ids.add(subQueryStr.substring(0, subQueryStr.indexOf(":1")));
+            }
+
+            assertEquals(expected.length, Iterables.size(ids));
+            assertThat(ids, CoreMatchers.hasItems(expected));
+        }
+    }
+
+    private void validateDeactivatedService() {
+        assertTrue("All data structures must be empty after deactivate", indexAugmentorFactory.isStateEmpty());
+    }
+
+    class IdentifiableIndexFiledProvider implements IndexFieldProvider {
+        private final Field id;
+        private final Set<String> nodeTypes;
+
+        IdentifiableIndexFiledProvider(String id, Set<String> nodeTypes) {
+            this.id = new StringField("id", id, Field.Store.NO);
+            this.nodeTypes = nodeTypes;
+            context.registerService(IndexFieldProvider.class, this);
+        }
+
+        @Nonnull
+        @Override
+        public Iterable<Field> getAugmentedFields(String path, NodeState document, NodeState indexDefinition) {
+            return Lists.newArrayList(id);
+        }
+
+        @Nonnull
+        @Override
+        public Set<String> getSupportedTypes() {
+            return nodeTypes;
+        }
+    }
+
+    class IdentifiableQueryTermsProvider implements FulltextQueryTermsProvider {
+        private final Query id;
+        private final Set<String> nodeTypes;
+
+        IdentifiableQueryTermsProvider(String id, Set<String> nodeTypes) {
+            this.id = (id == null)?null:new TermQuery(new Term(id, "1"));
+            this.nodeTypes = nodeTypes;
+            context.registerService(FulltextQueryTermsProvider.class, this);
+        }
+
+        @Override
+        public Query getQueryTerm(String text, Analyzer analyzer, NodeState indexDefinition) {
+            return id;
+        }
+
+        @Nonnull
+        @Override
+        public Set<String> getSupportedTypes() {
+            return nodeTypes;
+        }
+    }
+}