Author: natalia
Date: Mon Oct 5 02:09:28 2009
New Revision: 821662
URL: http://svn.apache.org/viewvc?rev=821662&view=rev
Log:
Update Lucene to version 2.9.0
Added:
xml/xindice/trunk/lib/lucene-core-2.9.0.jar (with props)
Removed:
xml/xindice/trunk/lib/lucene-core-2.4.0.jar
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/LuceneIndexer.java
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeReader.java
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeTermDocs.java
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/LuceneIndexer.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/LuceneIndexer.java?rev=821662&r1=821661&r2=821662&view=diff
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/LuceneIndexer.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/LuceneIndexer.java
Mon Oct 5 02:09:28 2009
@@ -29,10 +29,8 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.*;
+import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.DBException;
import org.apache.xindice.core.DBObject;
@@ -93,9 +91,9 @@
// Default analyzer to use
public static final String DEFANALYZER =
"org.apache.lucene.analysis.SimpleAnalyzer";
- private File idxFile;
- private IndexWriter iw;
- private Analyzer an;
+ private SimpleFSDirectory idxFile;
+ private IndexWriter iw;
+ private Analyzer an;
/**
* Most recently opened searcher. The same Searcher instance is going to
@@ -121,11 +119,11 @@
private String defaultField = "";
- private void setFile(File f) {
+ private void setFile(SimpleFSDirectory f) {
idxFile = f;
}
- private File getFile() {
+ private SimpleFSDirectory getFile() {
if (null == idxFile) {
throw new IllegalStateException("Not bound to a file");
}
@@ -235,7 +233,7 @@
}
}
- setFile(new File(collection.getCollectionRoot(), name));
+ setFile(new SimpleFSDirectory(new
File(collection.getCollectionRoot(), name), null));
} catch (Exception e) {
throw new XindiceException(e);
}
@@ -245,8 +243,12 @@
return config;
}
- public boolean exists() {
- return IndexReader.indexExists(idxFile);
+ public boolean exists() throws DBException {
+ try {
+ return IndexReader.indexExists(idxFile);
+ } catch (IOException e) {
+ throw new IndexerException(FaultCodes.GEN_GENERAL_ERROR, "Error
accessing index", e);
+ }
}
/**
@@ -298,7 +300,7 @@
try {
if (IndexReader.indexExists(idxFile)) {
close();
- return deepDelete(getFile());
+ return deepDelete(getFile().getFile());
} else {
return false;
}
@@ -530,7 +532,7 @@
public Searcher() throws DBException {
try {
- ir = IndexReader.open(getFile());
+ ir = IndexReader.open(getFile(), true);
is = new IndexSearcher(ir);
} catch (IOException e) {
throw new DBException(FaultCodes.IDX_CORRUPTED,
@@ -592,13 +594,13 @@
/**
* Internal search method.
* @param query Search query
- * @return Hits for the search
+ * @return TopDocs for the search
* @throws DBException Index could not be accessed
* @deprecated Deprecated following Lucene changes
*/
- public Hits search(Query query) throws DBException {
+ public TopDocs search(Query query) throws DBException {
try {
- return is.search(query);
+ return is.search(query, ir.numDocs());
} catch (IOException e) {
throw new DBException(FaultCodes.IDX_CORRUPTED,
"Failed to access index " + name + ",
collection " + collection.getCanonicalName(), e);
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeReader.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeReader.java?rev=821662&r1=821661&r2=821662&view=diff
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeReader.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeReader.java
Mon Oct 5 02:09:28 2009
@@ -30,7 +30,7 @@
import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.xindice.xml.dom.NodeImpl;
import org.w3c.dom.NodeList;
@@ -79,12 +79,14 @@
}
TokenStream stream = analyzer.tokenStream("", new
StringReader(text));
+ TermAttribute termAttr = (TermAttribute)
stream.addAttribute(TermAttribute.class);
try {
- Token reusableToken = new Token();
- Token token;
- while ((token = stream.next(reusableToken)) != null) {
- nodes[i].add(token.term());
+ stream.reset();
+ while (stream.incrementToken()) {
+ nodes[i].add(termAttr.term());
}
+ stream.end();
+ stream.close();
} catch (IOException e) {
// won't happen
}
@@ -259,7 +261,7 @@
/**
* Get text content of a DOM node. This is the same as DOM Level 3 method
* getTextContent().
- * @param node
+ * @param node DOM node
* @return The text content of this node and its descendants.
*/
private String getTextContent(Node node) {
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeTermDocs.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeTermDocs.java?rev=821662&r1=821661&r2=821662&view=diff
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeTermDocs.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/core/query/ftsearch/NodeTermDocs.java
Mon Oct 5 02:09:28 2009
@@ -55,6 +55,8 @@
freqs[idx]++;
}
}
+
+ num = 0;
}
public void seek(TermEnum termEnum) {
Added: xml/xindice/trunk/lib/lucene-core-2.9.0.jar
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/lib/lucene-core-2.9.0.jar?rev=821662&view=auto
==============================================================================
Binary file - no diff available.
Propchange: xml/xindice/trunk/lib/lucene-core-2.9.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream