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 ch...@apache.org on 2014/11/20 09:48:53 UTC
svn commit: r1640694 - in
/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene:
IndexDefinition.java LuceneIndex.java
Author: chetanm
Date: Thu Nov 20 08:48:53 2014
New Revision: 1640694
URL: http://svn.apache.org/r1640694
Log:
OAK-2261 - Enable support for NodeType based indexing rules (WIP)
Modified LuceneIndex also to switch to IndexingRule
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java?rev=1640694&r1=1640693&r2=1640694&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java Thu Nov 20 08:48:53 2014
@@ -44,7 +44,6 @@ import org.apache.jackrabbit.oak.api.Pro
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
import org.apache.jackrabbit.oak.plugins.tree.ImmutableTree;
@@ -101,12 +100,6 @@ class IndexDefinition {
private static final int TYPES_ALLOW_ALL = -1;
- private final int propertyTypes;
-
- private final Set<String> excludes;
-
- private final Set<String> includes;
-
private final boolean fullTextEnabled;
private final boolean propertyIndexEnabled;
@@ -150,11 +143,6 @@ class IndexDefinition {
this.root = root;
this.definition = defn;
this.indexName = determineIndexName(defn, indexPath);
- this.propertyTypes = getSupportedTypes(defn, TYPES_ALLOW_ALL);
-
- this.excludes = toLowerCase(getMultiProperty(defn, EXCLUDE_PROPERTY_NAMES));
- this.includes = getMultiProperty(defn, INCLUDE_PROPERTY_NAMES);
-
this.blobSize = getOptionalValue(defn, BLOB_SIZE, DEFAULT_BLOB_SIZE);
NodeState rulesState = defn.getChildNode(LuceneIndexConstants.INDEX_RULES);
@@ -185,20 +173,6 @@ class IndexDefinition {
}
}
- boolean includeProperty(String name) {
- if(!includes.isEmpty()){
- return includes.contains(name);
- }
- return !excludes.contains(name.toLowerCase());
- }
-
- boolean includePropertyType(int type){
- if(propertyTypes < 0){
- return false;
- }
- return (propertyTypes & (1 << type)) != 0;
- }
-
public boolean isFullTextEnabled() {
return fullTextEnabled;
}
@@ -207,15 +181,6 @@ class IndexDefinition {
return propertyIndexEnabled;
}
- public boolean skipTokenization(String propertyName) {
- //If fulltext is not enabled then we never tokenize
- //irrespective of property name
- if (!isFullTextEnabled()) {
- return true;
- }
- return LuceneIndexHelper.skipTokenization(propertyName);
- }
-
public String getFunctionName(){
return funcName;
}
@@ -284,17 +249,6 @@ class IndexDefinition {
//~------------------------------------------< Internal >
- private Map<String, RelativeProperty> collectRelativeProps(Iterable<String> propNames) {
- Map<String, RelativeProperty> relProps = newHashMap();
- for (String propName : propNames) {
- if (RelativeProperty.isRelativeProperty(propName)) {
- relProps.put(propName, new RelativeProperty(propName));
- }
- }
- return ImmutableMap.copyOf(relProps);
- }
-
-
private int getRelPropertyMaxLevels(Collection<RelativeProperty> props) {
int max = -1;
for (RelativeProperty prop : props) {
@@ -699,7 +653,7 @@ class IndexDefinition {
}
/**
- * @param path property name to match
+ * @param propertyPath property name to match
* @return <code>true</code> if <code>property name</code> matches this name
* pattern; <code>false</code> otherwise.
*/
Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1640694&r1=1640693&r2=1640694&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java Thu Nov 20 08:48:53 2014
@@ -53,8 +53,10 @@ import com.google.common.collect.Abstrac
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
+import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.PropertyValue;
import org.apache.jackrabbit.oak.plugins.index.aggregate.NodeAggregator;
+import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule;
import org.apache.jackrabbit.oak.plugins.index.lucene.util.MoreLikeThisHelper;
import org.apache.jackrabbit.oak.query.QueryEngineSettings;
import org.apache.jackrabbit.oak.query.QueryImpl;
@@ -529,6 +531,9 @@ public class LuceneIndex implements Adva
break;
}
+ //Fulltext index definition used by LuceneIndex only works with old format
+ //which is not nodeType based. So just use the nt:base index
+ IndexingRule rule = indexDefinition.getApplicableIndexingRule(JcrConstants.NT_BASE);
for (PropertyRestriction pr : filter.getPropertyRestrictions()) {
if (pr.first == null && pr.last == null) {
@@ -538,7 +543,7 @@ public class LuceneIndex implements Adva
}
// check excluded properties and types
- if (isExcludedProperty(pr, indexDefinition)) {
+ if (isExcludedProperty(pr, rule)) {
continue;
}
@@ -630,15 +635,16 @@ public class LuceneIndex implements Adva
}
private static boolean isExcludedProperty(PropertyRestriction pr,
- IndexDefinition definition) {
+ IndexingRule rule) {
String name = pr.propertyName;
if (name.contains("/")) {
// lucene cannot handle child-level property restrictions
return true;
}
+ PropertyDefinition pd = rule.getConfig(name);
// check name
- if(!definition.includeProperty(name)){
+ if(pd == null || !pd.index){
return true;
}
@@ -652,13 +658,20 @@ public class LuceneIndex implements Adva
type = pr.list.get(0).getType().tag();
}
if (type != null) {
- if (!definition.includePropertyType(type)) {
+ if (!includePropertyType(type, rule)) {
return true;
}
}
return false;
}
+ private static boolean includePropertyType(int type, IndexingRule rule){
+ if(rule.propertyTypes < 0){
+ return false;
+ }
+ return (rule.propertyTypes & (1 << type)) != 0;
+ }
+
private static void addReferenceConstraint(String uuid, List<Query> qs,
IndexReader reader) {
if (reader == null) {