Author: reto
Date: Thu Apr 11 10:35:11 2013
New Revision: 1466829
URL: http://svn.apache.org/r1466829
Log:
CLEREZZA-773: update to lucene 4.1.0
Modified:
clerezza/trunk/ext.org.apache.lucene/pom.xml
clerezza/trunk/platform.cris/pom.xml
clerezza/trunk/rdf.cris/core/pom.xml
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GenericCondition.java
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/SortSpecification.java
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/TermRangeCondition.java
clerezza/trunk/rdf.cris/core/src/test/java/org/apache/clerezza/rdf/cris/GraphIndexerTest.java
Modified: clerezza/trunk/ext.org.apache.lucene/pom.xml
URL:
http://svn.apache.org/viewvc/clerezza/trunk/ext.org.apache.lucene/pom.xml?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
--- clerezza/trunk/ext.org.apache.lucene/pom.xml (original)
+++ clerezza/trunk/ext.org.apache.lucene/pom.xml Thu Apr 11 10:35:11 2013
@@ -32,7 +32,7 @@
<description>Apache Lucene is a high-performance, full-featured text
search engine library written entirely in Java. It is a technology suitable for
nearly any application that requires full-text search, especially
cross-platfor</description>
<packaging>bundle</packaging>
<properties>
- <lucene-version>3.0.3</lucene-version>
+ <lucene-version>4.1.0</lucene-version>
</properties>
<dependencies>
<dependency>
@@ -42,22 +42,27 @@
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers</artifactId>
+ <artifactId>lucene-memory</artifactId>
<version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
- <artifactId>lucene-memory</artifactId>
+ <artifactId>lucene-queries</artifactId>
<version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
- <artifactId>lucene-queries</artifactId>
+ <artifactId>lucene-core</artifactId>
<version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
- <artifactId>lucene-core</artifactId>
+ <artifactId>lucene-queryparser</artifactId>
+ <version>${lucene-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers-common</artifactId>
<version>${lucene-version}</version>
</dependency>
</dependencies>
Modified: clerezza/trunk/platform.cris/pom.xml
URL:
http://svn.apache.org/viewvc/clerezza/trunk/platform.cris/pom.xml?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
--- clerezza/trunk/platform.cris/pom.xml (original)
+++ clerezza/trunk/platform.cris/pom.xml Thu Apr 11 10:35:11 2013
@@ -73,7 +73,7 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
- <version>3.0.3</version>
+ <version>4.1.0</version>
</dependency>
</dependencies>
<build>
Modified: clerezza/trunk/rdf.cris/core/pom.xml
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/pom.xml?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
--- clerezza/trunk/rdf.cris/core/pom.xml (original)
+++ clerezza/trunk/rdf.cris/core/pom.xml Thu Apr 11 10:35:11 2013
@@ -31,6 +31,9 @@
<version>0.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Clerezza - RDF Composite Resource Index Service Core</name>
+ <properties>
+ <lucene-version>4.1.0</lucene-version>
+ </properties>
<dependencies>
<dependency>
<groupId>org.apache.clerezza</groupId>
@@ -50,27 +53,22 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
- <version>3.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers</artifactId>
- <version>3.0.3</version>
+ <version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
- <version>3.0.3</version>
+ <version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
- <version>3.0.3</version>
+ <version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
- <version>3.0.3</version>
+ <version>${lucene-version}</version>
</dependency>
<dependency>
<groupId>org.wymiwyg</groupId>
@@ -81,6 +79,16 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-queryparser</artifactId>
+ <version>${lucene-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers-common</artifactId>
+ <version>${lucene-version}</version>
+ </dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Modified:
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GenericCondition.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GenericCondition.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GenericCondition.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GenericCondition.java
Thu Apr 11 10:35:11 2013
@@ -23,9 +23,9 @@ package org.apache.clerezza.rdf.cris;
import java.util.Collection;
import java.util.Iterator;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.MultiFieldQueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
+import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.Version;
@@ -73,9 +73,9 @@ public class GenericCondition extends Co
}
this.searchQuery = searchQuery;
- this.queryParser = new MultiFieldQueryParser(Version.LUCENE_30,
+ this.queryParser = new MultiFieldQueryParser(Version.LUCENE_41,
fields,
- new StandardAnalyzer(Version.LUCENE_30));
+ new StandardAnalyzer(Version.LUCENE_41));
queryParser.setAllowLeadingWildcard(true);
}
Modified:
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
Thu Apr 11 10:35:11 2013
@@ -50,7 +50,7 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
@@ -321,7 +321,7 @@ public class GraphIndexer extends Resour
this.definitionGraph = definitionGraph;
this.baseGraph = baseGraph;
this.maxHits = maxHits;
- analyzer = new StandardAnalyzer(Version.LUCENE_30);
+ analyzer = new StandardAnalyzer(Version.LUCENE_41);
luceneTools = new LuceneTools(indexDirectory, analyzer);
processDefinitions();
@@ -656,7 +656,7 @@ public class GraphIndexer extends Resour
sort = new Sort(sortSpecification.getSortFields());
sortCache.put(fieldKey, sort);
}
- searcher.setDefaultFieldSortScoring(true, true);
+ //searcher.setDefaultFieldSortScoring(true, true);
TopFieldDocs topFieldDocs = searcher.search(booleanQuery,
null, to, sort);
hits = topFieldDocs.scoreDocs;
} else {
Modified:
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
Thu Apr 11 10:35:11 2013
@@ -23,15 +23,19 @@ import java.io.File;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.logging.Level;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.AlreadyClosedException;
+import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,6 +49,7 @@ public class LuceneTools {
private final Logger logger = LoggerFactory.getLogger(getClass());
private IndexSearcher indexSearcher = null;
+ private DirectoryReader indexReader = null;
private Directory indexDirectory = null;
private IndexWriter indexWriter = null;
private Analyzer analyzer = null;
@@ -57,11 +62,10 @@ public class LuceneTools {
class IndexWriterWrapper extends IndexWriter {
private boolean invokeClose;
- public IndexWriterWrapper(Directory directory, Analyzer analyzer,
- boolean createDir, IndexWriter.MaxFieldLength mfl)
+ public IndexWriterWrapper(Directory directory, IndexWriterConfig conf)
throws CorruptIndexException, LockObtainFailedException,
IOException {
- super(directory, analyzer, createDir, mfl);
+ super(directory, conf);
invokeClose = true;
}
@@ -96,7 +100,7 @@ public class LuceneTools {
logger.info("Activating Lucene tools");
indexDirectory = indexDir;
if(indexDirectory instanceof FSDirectory) {
- luceneIndexDir = ((FSDirectory) indexDirectory).getFile();
+ luceneIndexDir = ((FSDirectory) indexDirectory).getDirectory();
}
this.analyzer = analyzer;
}
@@ -121,9 +125,9 @@ public class LuceneTools {
if(luceneIndexDir != null) {
indexDirectory = FSDirectory.open(luceneIndexDir);
}
- indexWriter = new IndexWriterWrapper(indexDirectory, getAnalyzer(),
- createDir, IndexWriter.MaxFieldLength.UNLIMITED);
- indexWriter.setMergeFactor(1000);
+ IndexWriterConfig config = new
IndexWriterConfig(Version.LUCENE_41, getAnalyzer());
+ indexWriter = new IndexWriterWrapper(indexDirectory, config);
+ //indexWriter.setMergeFactor(1000);
return indexWriter;
} catch (Exception ex) {
logger.error(ex.getMessage());
@@ -155,24 +159,46 @@ public class LuceneTools {
*
*/
public IndexSearcher getIndexSearcher() throws RuntimeException {
- try {
- if(indexSearcher != null) {
- if (indexSearcher.getIndexReader().isCurrent() ||
optimizeInProgress) {
- return indexSearcher;
- } else {
- indexSearcher.close();
- }
+ //TODO make sure a current version is returned
+ if (indexReader == null) {
+ try {
+ indexReader = DirectoryReader.open(indexDirectory);
+ indexSearcher = new IndexSearcher(indexReader);
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
}
- if (IndexReader.indexExists(indexDirectory)) {
- indexSearcher = new IndexSearcher(indexDirectory, true);
- return indexSearcher;
+
+ } else {
+ try {
+ DirectoryReader newReader =
DirectoryReader.openIfChanged(indexReader);
+ if (newReader != null) {
+ final IndexReader oldReader = indexReader;
+ indexReader = newReader;
+ //would be better to use ScheduledThreadPoolExecutor
+ new Thread() {
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
+ try {
+ oldReader.close();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ };
+ }
+ indexSearcher = new IndexSearcher(indexReader);
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
}
- } catch (CorruptIndexException ex) {
- logger.error(ex.getMessage());
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- throw new RuntimeException("Could not initialize IndexSearcher");
+ }
+ return indexSearcher;
}
/**
@@ -181,7 +207,7 @@ public class LuceneTools {
public void closeIndexSearcher() {
try {
if(indexSearcher != null) {
- indexSearcher.close();
+ //indexSearcher.close();
}
if(indexDirectory != null) {
indexDirectory.close();
@@ -207,9 +233,10 @@ public class LuceneTools {
* Starts index optimization. Optimization is started in a separate thread.
* This method does not wait for optimization to finish but returns
immediately
* after starting the optimize thread.
+ * //no more, see:
http://www.searchworkings.org/blog/-/blogs/simon-says%3A-optimize-is-bad-for-you
*/
synchronized public void optimizeIndex() {
- if(optimizeInProgress) {
+ /* if(optimizeInProgress) {
return;
}
new Thread(new Runnable() {
@@ -240,7 +267,7 @@ public class LuceneTools {
}
});
}
- }).start();
+ }).start();*/
}
@Override
Modified:
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
Thu Apr 11 10:35:11 2013
@@ -23,8 +23,9 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.clerezza.rdf.core.NonLiteral;
import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.queryparser.classic.QueryParser;
+
/**
* A searchable index.
Modified:
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/SortSpecification.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/SortSpecification.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/SortSpecification.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/SortSpecification.java
Thu Apr 11 10:35:11 2013
@@ -16,59 +16,92 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.clerezza.rdf.cris;
import java.util.ArrayList;
import org.apache.lucene.search.SortField;
/**
- * Specifies CRIS result sorting.
+ * Specifies CRIS result sorting.
*
* @author daniel
*/
public class SortSpecification {
-
- /**
- * Interpret values as bytes.
- */
- public static final int BYTE = SortField.BYTE;
-
- /**
- * Interpret values as doubles.
- */
- public static final int DOUBLE = SortField.DOUBLE;
-
- /**
- * Interpret values as floats.
- */
- public static final int FLOAT = SortField.FLOAT;
-
- /**
- * Interpret values as integers.
- */
- public static final int INT = SortField.INT;
-
- /**
- * Interpret values as longs.
- */
- public static final int LONG = SortField.LONG;
-
- /**
- * Interpret values as shorts.
- */
- public static final int SHORT = SortField.SHORT;
-
- /**
- * Interpret values as strings (using ordinals, faster).
- */
- public static final int STRING = SortField.STRING;
-
+
+ //pexact copy of SortFiled.Type
/**
- * Interpret values as strings (using compareTo, slower).
+ * Specifies the type of the terms to be sorted, or special types such as
+ * CUSTOM
*/
- public static final int STRING_COMPARETO = SortField.STRING_VAL;
-
+ public static enum Type {
+
+ /**
+ * Sort by document score (relevance). Sort values are Float and higher
+ * values are at the front.
+ */
+ SCORE,
+ /**
+ * Sort by document number (index order). Sort values are Integer and
+ * lower values are at the front.
+ */
+ DOC,
+ /**
+ * Sort using term values as Strings. Sort values are String and lower
+ * values are at the front.
+ */
+ STRING,
+ /**
+ * Sort using term values as encoded Integers. Sort values are Integer
+ * and lower values are at the front.
+ */
+ INT,
+ /**
+ * Sort using term values as encoded Floats. Sort values are Float and
+ * lower values are at the front.
+ */
+ FLOAT,
+ /**
+ * Sort using term values as encoded Longs. Sort values are Long and
+ * lower values are at the front.
+ */
+ LONG,
+ /**
+ * Sort using term values as encoded Doubles. Sort values are Double
and
+ * lower values are at the front.
+ */
+ DOUBLE,
+ /**
+ * Sort using term values as encoded Shorts. Sort values are Short and
+ * lower values are at the front.
+ */
+ SHORT,
+ /**
+ * Sort using a custom Comparator. Sort values are any Comparable and
+ * sorting is done according to natural order.
+ */
+ CUSTOM,
+ /**
+ * Sort using term values as encoded Bytes. Sort values are Byte and
+ * lower values are at the front.
+ */
+ BYTE,
+ /**
+ * Sort using term values as Strings, but comparing by value (using
+ * String.compareTo) for all comparisons. This is typically slower than
+ * {@link #STRING}, which uses ordinals to do the sorting.
+ */
+ STRING_VAL,
+ /**
+ * Sort use byte[] index values.
+ */
+ BYTES,
+ /**
+ * Force rewriting of SortField using
+ * {@link SortField#rewrite(IndexSearcher)} before it can be used for
+ * sorting
+ */
+ REWRITEABLE
+ }
/**
* Sort by indexing order (first indexed resource is first, etc.).
*/
@@ -78,7 +111,6 @@ public class SortSpecification {
return SortField.FIELD_DOC;
}
};
-
/**
* Sort by Lucene document score.
*/
@@ -88,14 +120,18 @@ public class SortSpecification {
return SortField.FIELD_SCORE;
}
};
-
+
/**
* A SortSPecification Entry.
*/
public static class SortEntry {
+
private SortField sortField;
-
- private SortEntry() {};
+
+ private SortEntry() {
+ }
+
+ ;
/**
* Constructor.
@@ -104,14 +140,14 @@ public class SortSpecification {
* @param type The property-values type.
* @param reverse True sorts in reverse. False uses standard order.
*/
- SortEntry(VirtualProperty property, int type, boolean reverse) {
- sortField = new SortField(GraphIndexer.SORT_PREFIX +
property.getStringKey(), type, reverse);
+ SortEntry(VirtualProperty property, Type type, boolean reverse) {
+ sortField = new SortField(GraphIndexer.SORT_PREFIX +
property.getStringKey(), SortField.Type.valueOf(type.name()), reverse);
}
-
+
/**
* Return a the Lucene SortField corresponding to this entry.
- *
- * @return the SortField
+ *
+ * @return the SortField
*/
SortField getSortField() {
return sortField;
@@ -119,10 +155,10 @@ public class SortSpecification {
@Override
public boolean equals(Object obj) {
- if(obj == null) {
+ if (obj == null) {
return false;
}
- if(!(obj instanceof SortEntry)) {
+ if (!(obj instanceof SortEntry)) {
return false;
}
return getSortField().equals(((SortEntry) obj).getSortField());
@@ -133,7 +169,6 @@ public class SortSpecification {
return getSortField().hashCode();
}
}
-
private ArrayList<SortEntry> sortPriority;
/**
@@ -142,115 +177,112 @@ public class SortSpecification {
public SortSpecification() {
sortPriority = new ArrayList<SortEntry>();
}
-
+
/**
* Add a property to sort on.
- *
- * Note:
- * The order of addition determines the search priority.
- * The property to search on has to be indexed.
- * The indexed value should not be tokenized.
- * The property's value is interpreted according to specified type.
- *
- * @param property the property
- * @param type the type
+ *
+ * Note: The order of addition determines the search priority. The property
+ * to search on has to be indexed. The indexed value should not be
+ * tokenized. The property's value is interpreted according to specified
+ * type.
+ *
+ * @param property the property
+ * @param type the type
*/
- public void add(VirtualProperty property, int type) {
+ public void add(VirtualProperty property, Type type) {
add(property, type, false);
}
-
+
/**
* Add a property to sort on.
- *
- * Note:
- * The order of addition determines the search priority.
- * The property to search on has to be indexed.
- * The indexed value should not be tokenized.
- * The property's value is interpreted according to specified type.
- *
- * @param property the property
- * @param type the type
+ *
+ * Note: The order of addition determines the search priority. The property
+ * to search on has to be indexed. The indexed value should not be
+ * tokenized. The property's value is interpreted according to specified
+ * type.
+ *
+ * @param property the property
+ * @param type the type
* @param reverse whether to sort in reverse.
*/
- public void add(VirtualProperty property, int type, boolean reverse) {
+ public void add(VirtualProperty property, Type type, boolean reverse) {
SortEntry sortEntry = new SortEntry(property, type, reverse);
add(sortEntry);
}
-
+
/**
* Add a SortEntry.
- *
- * Note:
- * The order of addition determines the search priority.
+ *
+ * Note: The order of addition determines the search priority.
*/
public void add(SortEntry entry) {
- if(!sortPriority.contains(entry)) {
+ if (!sortPriority.contains(entry)) {
sortPriority.add(entry);
}
}
-
+
/**
* Remove the property with specified type.
- *
+ *
* @param property the property.
* @param type the type.
*/
- public void remove(VirtualProperty property, int type) {
+ public void remove(VirtualProperty property, Type type) {
remove(property, type, false);
}
-
+
/**
* Remove the property with specified type.
- *
+ *
* @param property the property.
* @param type the type.
* @param reverse whether the sort is specified in reverse.
*/
- public void remove(VirtualProperty property, int type, boolean reverse) {
+ public void remove(VirtualProperty property, Type type, boolean reverse) {
SortEntry sortEntry = new SortEntry(property, type, reverse);
remove(sortEntry);
}
-
+
/**
* Remove a SortEntry.
*/
public void remove(SortEntry entry) {
ArrayList<SortEntry> old = new ArrayList<SortEntry>(sortPriority);
sortPriority.clear();
- for(SortEntry e : old) {
- if(!e.equals(entry)) {
+ for (SortEntry e : old) {
+ if (!e.equals(entry)) {
sortPriority.add(e);
}
}
}
-
+
/**
* Clear the sort specification.
*/
public void clear() {
sortPriority.clear();
}
-
+
/**
* Returns the number of added entries.
- *
- * @return the number of entries.
+ *
+ * @return the number of entries.
*/
public int size() {
return sortPriority.size();
}
-
+
/**
* Get all entries as SortFields.
- *
- * @return the SortFields
+ *
+ * @return the SortFields
*/
SortField[] getSortFields() {
SortField[] array = new SortField[size()];
- for(int i = 0; i < size(); ++i) {
+ for (int i = 0; i < size(); ++i) {
array[i] = sortPriority.get(i).getSortField();
}
-
+
return array;
}
}
Modified:
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/TermRangeCondition.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/TermRangeCondition.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/TermRangeCondition.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/TermRangeCondition.java
Thu Apr 11 10:35:11 2013
@@ -22,6 +22,7 @@ package org.apache.clerezza.rdf.cris;
import org.apache.clerezza.rdf.core.UriRef;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermRangeQuery;
+import org.apache.lucene.util.BytesRef;
/**
* Allows searches for rangers of terms.
@@ -87,6 +88,6 @@ public class TermRangeCondition extends
@Override
public Query query() {
- return new TermRangeQuery(property.stringKey, lowerTerm, upperTerm,
includeUpper, includeLower);
+ return new TermRangeQuery(property.stringKey, new BytesRef(lowerTerm),
new BytesRef(upperTerm), includeUpper, includeLower);
}
}
Modified:
clerezza/trunk/rdf.cris/core/src/test/java/org/apache/clerezza/rdf/cris/GraphIndexerTest.java
URL:
http://svn.apache.org/viewvc/clerezza/trunk/rdf.cris/core/src/test/java/org/apache/clerezza/rdf/cris/GraphIndexerTest.java?rev=1466829&r1=1466828&r2=1466829&view=diff
==============================================================================
---
clerezza/trunk/rdf.cris/core/src/test/java/org/apache/clerezza/rdf/cris/GraphIndexerTest.java
(original)
+++
clerezza/trunk/rdf.cris/core/src/test/java/org/apache/clerezza/rdf/cris/GraphIndexerTest.java
Thu Apr 11 10:35:11 2013
@@ -33,7 +33,7 @@ import org.apache.clerezza.rdf.ontologie
import org.apache.clerezza.rdf.ontologies.RDF;
import org.apache.clerezza.rdf.ontologies.RDFS;
import org.apache.clerezza.rdf.utils.*;
-import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryparser.classic.ParseException;
import org.junit.*;
import org.wymiwyg.commons.util.Util;
@@ -517,7 +517,7 @@ public class GraphIndexerTest {
service.reCreateIndex();
SortSpecification sortSpecification = new SortSpecification();
- sortSpecification.add(firstName, SortSpecification.STRING_COMPARETO);
+ sortSpecification.add(firstName, SortSpecification.Type.STRING_VAL);
sortSpecification.add(SortSpecification.INDEX_ORDER);
Thread.sleep(1000);
@@ -562,7 +562,7 @@ public class GraphIndexerTest {
service.reCreateIndex();
SortSpecification sortSpecification = new SortSpecification();
- sortSpecification.add(firstName, SortSpecification.STRING_COMPARETO);
+ sortSpecification.add(firstName, SortSpecification.Type.STRING_VAL);
sortSpecification.add(SortSpecification.INDEX_ORDER);
Thread.sleep(1000);