Author: rhauch
Date: 2009-09-29 13:28:50 -0400 (Tue, 29 Sep 2009)
New Revision: 1276
Modified:
trunk/dna-search/src/main/java/org/jboss/dna/search/DirectoryConfigurations.java
trunk/dna-search/src/main/java/org/jboss/dna/search/IndexContext.java
trunk/dna-search/src/main/java/org/jboss/dna/search/StoreLittleIndexingStrategy.java
trunk/dna-search/src/main/java/org/jboss/dna/search/WorkspaceSearchEngine.java
Log:
Merge branch 'dna-529'
Modified:
trunk/dna-search/src/main/java/org/jboss/dna/search/DirectoryConfigurations.java
===================================================================
---
trunk/dna-search/src/main/java/org/jboss/dna/search/DirectoryConfigurations.java 2009-09-29
16:14:30 UTC (rev 1275)
+++
trunk/dna-search/src/main/java/org/jboss/dna/search/DirectoryConfigurations.java 2009-09-29
17:28:50 UTC (rev 1276)
@@ -313,7 +313,7 @@
*/
protected FSDirectory create( File directory,
LockFactory lockFactory ) throws IOException {
- return FSDirectory.getDirectory(directory, lockFactory);
+ return FSDirectory.open(directory, lockFactory);
}
}
Modified: trunk/dna-search/src/main/java/org/jboss/dna/search/IndexContext.java
===================================================================
--- trunk/dna-search/src/main/java/org/jboss/dna/search/IndexContext.java 2009-09-29
16:14:30 UTC (rev 1275)
+++ trunk/dna-search/src/main/java/org/jboss/dna/search/IndexContext.java 2009-09-29
17:28:50 UTC (rev 1276)
@@ -47,6 +47,7 @@
private final Directory contentIndexDirectory;
private final Analyzer analyzer;
private final boolean overwrite;
+ private final boolean readOnly;
private final ValueFactory<String> stringFactory;
private final DateTimeFactory dateFactory;
private IndexReader pathsReader;
@@ -60,7 +61,8 @@
Directory pathsIndexDirectory,
Directory contentIndexDirectory,
Analyzer analyzer,
- boolean overwrite ) {
+ boolean overwrite,
+ boolean readOnly ) {
assert context != null;
assert pathsIndexDirectory != null;
assert contentIndexDirectory != null;
@@ -71,6 +73,7 @@
this.overwrite = overwrite;
this.stringFactory = context.getValueFactories().getStringFactory();
this.dateFactory = context.getValueFactories().getDateFactory();
+ this.readOnly = readOnly;
}
/**
@@ -97,14 +100,14 @@
public IndexReader getPathsReader() throws IOException {
if (pathsReader == null) {
- pathsReader = IndexReader.open(pathsIndexDirectory);
+ pathsReader = IndexReader.open(pathsIndexDirectory, readOnly);
}
return pathsReader;
}
public IndexReader getContentReader() throws IOException {
if (contentReader == null) {
- contentReader = IndexReader.open(contentIndexDirectory);
+ contentReader = IndexReader.open(contentIndexDirectory, readOnly);
}
return contentReader;
}
Modified:
trunk/dna-search/src/main/java/org/jboss/dna/search/StoreLittleIndexingStrategy.java
===================================================================
---
trunk/dna-search/src/main/java/org/jboss/dna/search/StoreLittleIndexingStrategy.java 2009-09-29
16:14:30 UTC (rev 1275)
+++
trunk/dna-search/src/main/java/org/jboss/dna/search/StoreLittleIndexingStrategy.java 2009-09-29
17:28:50 UTC (rev 1276)
@@ -45,8 +45,8 @@
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocCollector;
import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.util.Version;
import org.jboss.dna.common.text.NoOpEncoder;
import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.common.util.Logger;
@@ -166,7 +166,7 @@
* @see org.jboss.dna.search.IndexingStrategy#createAnalyzer()
*/
public Analyzer createAnalyzer() {
- return new StandardAnalyzer();
+ return new StandardAnalyzer(Version.LUCENE_CURRENT);
}
/**
@@ -318,11 +318,9 @@
// Parse the full-text search and search against the 'fts' field ...
QueryParser parser = new QueryParser(ContentIndex.FULL_TEXT, createAnalyzer());
Query query = parser.parse(fullTextString);
- TopDocCollector collector = new TopDocCollector(maxResults + offset);
- indexes.getContentSearcher().search(query, collector);
+ TopDocs docs = indexes.getContentSearcher().search(query, maxResults + offset);
// Collect the results ...
- TopDocs docs = collector.topDocs();
IndexReader contentReader = indexes.getContentReader();
IndexReader pathReader = indexes.getPathsReader();
IndexSearcher pathSearcher = indexes.getPathsSearcher();
Modified: trunk/dna-search/src/main/java/org/jboss/dna/search/WorkspaceSearchEngine.java
===================================================================
---
trunk/dna-search/src/main/java/org/jboss/dna/search/WorkspaceSearchEngine.java 2009-09-29
16:14:30 UTC (rev 1275)
+++
trunk/dna-search/src/main/java/org/jboss/dna/search/WorkspaceSearchEngine.java 2009-09-29
17:28:50 UTC (rev 1276)
@@ -283,8 +283,17 @@
*/
protected final void execute( boolean overwrite,
Activity... activities ) throws SearchEngineException
{
+ // Determine if the activities are readonly ...
+ boolean readOnly = true;
+ for (Activity activity : activities) {
+ if (!(activity instanceof ReadOnlyActivity)) {
+ readOnly = false;
+ break;
+ }
+ }
+
Analyzer analyzer = this.indexingStrategy.createAnalyzer();
- IndexContext indexes = new IndexContext(encodedContext, pathsDirectory,
contentDirectory, analyzer, overwrite);
+ IndexContext indexes = new IndexContext(encodedContext, pathsDirectory,
contentDirectory, analyzer, overwrite, readOnly);
// Execute the various activities ...
Throwable error = null;
@@ -343,6 +352,8 @@
* Interface for activities that will be executed against the set of indexes. These
activities don't have to commit or roll
* back the writer, nor do they have to translate the exceptions, since this is done
by the
* {@link WorkspaceSearchEngine#execute(boolean, Activity...)} method.
+ *
+ * @see ReadOnlyActivity
*/
protected interface Activity {
@@ -364,7 +375,10 @@
String messageFor( Throwable t );
}
- protected interface Search extends Activity {
+ protected interface ReadOnlyActivity extends Activity {
+ }
+
+ protected interface Search extends ReadOnlyActivity {
/**
* Get the results of the search.
*
@@ -373,7 +387,7 @@
List<Location> getResults();
}
- protected interface Query extends Activity {
+ protected interface Query extends ReadOnlyActivity {
/**
* Get the results of the query.
*