/** * Creates a new indexing rule base on an existing one, but for a * different node type name. * * @param original the existing rule. * @param nodeTypeName the node type name for the rule. */ IndexingRule(IndexingRule original, String nodeTypeName) { this.nodeTypeName = nodeTypeName; this.baseNodeType = original.getNodeTypeName(); this.propConfigs = original.propConfigs; this.namePatterns = original.namePatterns; this.boost = original.boost; this.inherited = original.inherited; this.propertyTypes = original.propertyTypes; this.propertyIndexEnabled = original.propertyIndexEnabled; this.propAggregate = original.propAggregate; this.nullCheckEnabledProperties = original.nullCheckEnabledProperties; this.notNullCheckEnabledProperties = original.notNullCheckEnabledProperties; this.functionRestrictions = original.functionRestrictions; this.nodeScopeAnalyzedProps = original.nodeScopeAnalyzedProps; this.aggregate = combine(propAggregate, nodeTypeName); this.fulltextEnabled = aggregate.hasNodeAggregates() || original.fulltextEnabled; this.nodeFullTextIndexed = aggregate.hasNodeAggregates() || original.nodeFullTextIndexed; this.indexesAllNodesOfMatchingType = areAlMatchingNodeByTypeIndexed(); this.nodeNameIndexed = original.nodeNameIndexed; this.syncProps = original.syncProps; this.similarityProperties = original.similarityProperties; }
this.notNullCheckEnabledProperties = ImmutableList.copyOf(existentProperties); this.similarityProperties = ImmutableList.copyOf(similarityProperties); this.fulltextEnabled = aggregate.hasNodeAggregates() || hasAnyFullTextEnabledProperty(); this.nodeFullTextIndexed = aggregate.hasNodeAggregates() || anyNodeScopeIndexedProperty(); this.propertyIndexEnabled = hasAnyPropertyIndexConfigured(); this.indexesAllNodesOfMatchingType = areAlMatchingNodeByTypeIndexed();
@Test public void regexAllProps() { IndexDefinitionBuilder builder = new IndexDefinitionBuilder(); builder.indexRule("nt:base").property("p"); builder.indexRule("nt:base").property("all", FulltextIndexConstants.REGEX_ALL_PROPS, true); IndexDefinition def = IndexDefinition.newBuilder(root, builder.build(), "/foo").build(); IndexingRule rule = def.getApplicableIndexingRule(root); assertNotNull(rule); PropertyDefinition pd = rule.getConfig("p"); assertNotNull(pd); assertFalse(pd.isRegexp); assertFalse(pd.relative); assertEquals(0, pd.ancestors.length); pd = rule.getConfig("all"); assertNotNull(pd); assertTrue(pd.isRegexp); assertFalse(pd.relative); assertEquals(0, pd.ancestors.length); assertThat(rule.getAggregate().getIncludes(), is(empty())); assertFalse(rule.getAggregate().hasNodeAggregates()); List<Aggregate.Matcher> matchers = rule.getAggregate() .createMatchers(new TestRoot("/")); assertThat(matchers, is(empty())); assertThat(def.getRelativeNodeNames(), is(empty())); }
@Test public void regexAllProps() { IndexDefinitionBuilder builder = new IndexDefinitionBuilder(); builder.indexRule("nt:base").property("p"); builder.indexRule("nt:base").property("all", FulltextIndexConstants.REGEX_ALL_PROPS, true); IndexDefinition def = IndexDefinition.newBuilder(root, builder.build(), "/foo").build(); IndexingRule rule = def.getApplicableIndexingRule(root); assertNotNull(rule); PropertyDefinition pd = rule.getConfig("p"); assertNotNull(pd); assertFalse(pd.isRegexp); assertFalse(pd.relative); assertEquals(0, pd.ancestors.length); pd = rule.getConfig("all"); assertNotNull(pd); assertTrue(pd.isRegexp); assertFalse(pd.relative); assertEquals(0, pd.ancestors.length); assertThat(rule.getAggregate().getIncludes(), is(empty())); assertFalse(rule.getAggregate().hasNodeAggregates()); List<Aggregate.Matcher> matchers = rule.getAggregate() .createMatchers(new TestRoot("/")); assertThat(matchers, is(empty())); assertThat(def.getRelativeNodeNames(), is(empty())); }