You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2005/02/18 14:31:25 UTC
svn commit: r154282 -
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
Author: mreutegg
Date: Fri Feb 18 05:31:24 2005
New Revision: 154282
URL: http://svn.apache.org/viewcvs?view=rev&rev=154282
Log:
jcr:system is not indexed when workspace is created.
Modified:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java?view=diff&r1=154281&r2=154282
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java Fri Feb 18 05:31:24 2005
@@ -24,6 +24,7 @@
import org.apache.jackrabbit.core.search.ExecutableQuery;
import org.apache.jackrabbit.core.state.NodeState;
import org.apache.jackrabbit.core.state.ItemStateException;
+import org.apache.jackrabbit.core.state.ItemStateManager;
import org.apache.jackrabbit.core.SessionImpl;
import org.apache.jackrabbit.core.ItemManager;
import org.apache.jackrabbit.core.QName;
@@ -42,6 +43,8 @@
import javax.jcr.query.InvalidQueryException;
import javax.jcr.RepositoryException;
import java.io.IOException;
+import java.util.List;
+import java.util.Iterator;
/**
* Implements a {@link org.apache.jackrabbit.core.search.QueryHandler} using
@@ -107,7 +110,7 @@
if (create) {
// index root node
NodeState rootState = (NodeState) getItemStateProvider().getItemState(new NodeId(getRootUUID()));
- addNode(rootState);
+ createIndex(rootState);
}
} catch (ItemStateException e) {
throw new IOException("Error indexing root node: " + e.getMessage());
@@ -213,6 +216,16 @@
persistentIndex.close();
}
+ /**
+ * Executes the query on the search index.
+ * @param query the lucene query.
+ * @param orderProps name of the properties for sort order.
+ * @param orderSpecs the order specs for the sort order properties.
+ * <code>true</code> indicates ascending order, <code>false</code> indicates
+ * descending.
+ * @return the lucene Hits object.
+ * @throws IOException if an error occurs while searching the index.
+ */
Hits executeQuery(Query query,
QName[] orderProps,
boolean[] orderSpecs) throws IOException {
@@ -256,12 +269,40 @@
return hits;
}
+ /**
+ * Returns the analyzer in use for indexing.
+ * @return the analyzer in use for indexing.
+ */
Analyzer getAnalyzer() {
return analyzer;
}
+ /**
+ * Returns the namespace mappings for the internal representation.
+ * @return the namespace mappings for the internal representation.
+ */
NamespaceMappings getNamespaceMappings() {
return nsMappings;
+ }
+
+ //---------------------------< internal >-----------------------------------
+
+ /**
+ * Recursively creates an index starting with the NodeState <code>node</code>.
+ * @param node the current NodeState.
+ * @throws IOException if an error occurs while writing to the index.
+ * @throws ItemStateException if an node state cannot be found.
+ * @throws RepositoryException if any other error occurs
+ */
+ private void createIndex(NodeState node)
+ throws IOException, ItemStateException, RepositoryException {
+ addNode(node);
+ List children = node.getChildNodeEntries();
+ ItemStateManager isMgr = getItemStateProvider();
+ for (Iterator it = children.iterator(); it.hasNext();) {
+ NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry) it.next();
+ createIndex((NodeState) isMgr.getItemState(new NodeId(child.getUUID())));
+ }
}
//--------------------------< properties >----------------------------------