|
|
e62044 |
diff --git a/org.eclipse.mylyn.tasks.index.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.index.core/META-INF/MANIFEST.MF
|
|
|
e62044 |
index 44080b1..962ff79 100644
|
|
|
e62044 |
--- org.eclipse.mylyn.tasks.index.core/META-INF/MANIFEST.MF
|
|
|
e62044 |
+++ org.eclipse.mylyn.tasks.index.core/META-INF/MANIFEST.MF
|
|
|
e62044 |
@@ -7,7 +7,9 @@ Bundle-Vendor: %Bundle-Vendor
|
|
|
e62044 |
Require-Bundle: org.eclipse.core.runtime,
|
|
|
e62044 |
org.eclipse.mylyn.tasks.core;bundle-version="3.8.0",
|
|
|
e62044 |
org.eclipse.mylyn.commons.core;bundle-version="3.8.0",
|
|
|
e62044 |
- org.apache.lucene.core;bundle-version="[2.9.1,3.7.0)"
|
|
|
e62044 |
+ org.apache.lucene.core;bundle-version="[4.0.0,5.0.0)",
|
|
|
e62044 |
+ org.apache.lucene.queryparser;bundle-version="[4.0.0,5.0.0)",
|
|
|
e62044 |
+ org.apache.lucene.analysis;bundle-version="[4.0.0,5.0.0)"
|
|
|
e62044 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
|
e62044 |
Bundle-ActivationPolicy: lazy
|
|
|
e62044 |
Export-Package: org.eclipse.mylyn.internal.tasks.index.core;x-internal:=true
|
|
|
e62044 |
diff --git a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskAnalyzer.java b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskAnalyzer.java
|
|
|
e62044 |
index b1b88c1..1cbf72c 100644
|
|
|
e62044 |
--- org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskAnalyzer.java
|
|
|
e62044 |
+++ org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskAnalyzer.java
|
|
|
e62044 |
@@ -11,8 +11,12 @@
|
|
|
e62044 |
*******************************************************************************/
|
|
|
e62044 |
package org.eclipse.mylyn.internal.tasks.index.core;
|
|
|
e62044 |
|
|
|
e62044 |
-import org.apache.lucene.analysis.KeywordAnalyzer;
|
|
|
e62044 |
-import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
|
|
|
e62044 |
+import java.util.HashMap;
|
|
|
e62044 |
+import java.util.Map;
|
|
|
e62044 |
+
|
|
|
e62044 |
+import org.apache.lucene.analysis.Analyzer;
|
|
|
e62044 |
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
|
|
|
e62044 |
+import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
|
|
|
e62044 |
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
|
|
e62044 |
import org.apache.lucene.util.Version;
|
|
|
e62044 |
|
|
|
e62044 |
@@ -24,10 +28,12 @@ import org.apache.lucene.util.Version;
|
|
|
e62044 |
class TaskAnalyzer {
|
|
|
e62044 |
|
|
|
e62044 |
public static PerFieldAnalyzerWrapper instance() {
|
|
|
e62044 |
- PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_CURRENT));
|
|
|
e62044 |
- wrapper.addAnalyzer(TaskListIndex.FIELD_IDENTIFIER.getIndexKey(), new KeywordAnalyzer());
|
|
|
e62044 |
- wrapper.addAnalyzer(TaskListIndex.FIELD_TASK_KEY.getIndexKey(), new KeywordAnalyzer());
|
|
|
e62044 |
- wrapper.addAnalyzer(TaskListIndex.FIELD_REPOSITORY_URL.getIndexKey(), new KeywordAnalyzer());
|
|
|
e62044 |
+ Map<String, Analyzer> analyzerPerField = new HashMap<String, Analyzer>();
|
|
|
e62044 |
+ analyzerPerField.put(TaskListIndex.FIELD_IDENTIFIER.getIndexKey(), new KeywordAnalyzer());
|
|
|
e62044 |
+ analyzerPerField.put(TaskListIndex.FIELD_TASK_KEY.getIndexKey(), new KeywordAnalyzer());
|
|
|
e62044 |
+ analyzerPerField.put(TaskListIndex.FIELD_REPOSITORY_URL.getIndexKey(), new KeywordAnalyzer());
|
|
|
e62044 |
+ PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_CURRENT),
|
|
|
e62044 |
+ analyzerPerField);
|
|
|
e62044 |
return wrapper;
|
|
|
e62044 |
}
|
|
|
e62044 |
}
|
|
|
e62044 |
--- org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java.sav 2014-03-28 12:12:59.000000000 +0200
|
|
|
e62044 |
+++ org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java 2014-03-31 14:52:27.320005081 +0300
|
|
|
e62044 |
@@ -38,12 +38,16 @@ import org.apache.lucene.document.DateTo
|
|
|
e62044 |
import org.apache.lucene.document.Document;
|
|
|
e62044 |
import org.apache.lucene.document.Field;
|
|
|
e62044 |
import org.apache.lucene.document.Field.Store;
|
|
|
e62044 |
+import org.apache.lucene.document.StringField;
|
|
|
e62044 |
import org.apache.lucene.index.CorruptIndexException;
|
|
|
e62044 |
+import org.apache.lucene.index.DirectoryReader;
|
|
|
e62044 |
import org.apache.lucene.index.IndexReader;
|
|
|
e62044 |
import org.apache.lucene.index.IndexWriter;
|
|
|
e62044 |
+import org.apache.lucene.index.IndexWriterConfig;
|
|
|
e62044 |
+import org.apache.lucene.index.IndexableField;
|
|
|
e62044 |
import org.apache.lucene.index.Term;
|
|
|
e62044 |
-import org.apache.lucene.queryParser.ParseException;
|
|
|
e62044 |
-import org.apache.lucene.queryParser.QueryParser;
|
|
|
e62044 |
+import org.apache.lucene.queryparser.classic.ParseException;
|
|
|
e62044 |
+import org.apache.lucene.queryparser.classic.QueryParser;
|
|
|
e62044 |
import org.apache.lucene.search.BooleanClause;
|
|
|
e62044 |
import org.apache.lucene.search.BooleanClause.Occur;
|
|
|
e62044 |
import org.apache.lucene.search.BooleanQuery;
|
|
|
e62044 |
@@ -591,12 +595,6 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
} catch (IOException e) {
|
|
|
e62044 |
StatusHandler.log(new Status(IStatus.ERROR, TasksIndexCore.ID_PLUGIN,
|
|
|
e62044 |
"Unexpected failure within task list index", e)); //$NON-NLS-1$
|
|
|
e62044 |
- } finally {
|
|
|
e62044 |
- try {
|
|
|
e62044 |
- indexSearcher.close();
|
|
|
e62044 |
- } catch (IOException e) {
|
|
|
e62044 |
- // ignore
|
|
|
e62044 |
- }
|
|
|
e62044 |
}
|
|
|
e62044 |
|
|
|
e62044 |
} else {
|
|
|
e62044 |
@@ -674,12 +672,6 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
} catch (IOException e) {
|
|
|
e62044 |
StatusHandler.log(new Status(IStatus.ERROR, TasksIndexCore.ID_PLUGIN,
|
|
|
e62044 |
"Unexpected failure within task list index", e)); //$NON-NLS-1$
|
|
|
e62044 |
- } finally {
|
|
|
e62044 |
- try {
|
|
|
e62044 |
- indexSearcher.close();
|
|
|
e62044 |
- } catch (IOException e) {
|
|
|
e62044 |
- // ignore
|
|
|
e62044 |
- }
|
|
|
e62044 |
}
|
|
|
e62044 |
}
|
|
|
e62044 |
} finally {
|
|
|
e62044 |
@@ -769,7 +761,7 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
try {
|
|
|
e62044 |
synchronized (this) {
|
|
|
e62044 |
if (indexReader == null) {
|
|
|
e62044 |
- indexReader = IndexReader.open(directory, true);
|
|
|
e62044 |
+ indexReader = DirectoryReader.open(directory);
|
|
|
e62044 |
lastResults = null;
|
|
|
e62044 |
}
|
|
|
e62044 |
return indexReader;
|
|
|
e62044 |
@@ -983,7 +975,7 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
if (value == null) {
|
|
|
e62044 |
return;
|
|
|
e62044 |
}
|
|
|
e62044 |
- Field field = document.getField(indexField.getIndexKey());
|
|
|
e62044 |
+ IndexableField field = document.getField(indexField.getIndexKey());
|
|
|
e62044 |
if (field == null) {
|
|
|
e62044 |
field = new Field(indexField.getIndexKey(), value, Store.YES,
|
|
|
e62044 |
org.apache.lucene.document.Field.Index.ANALYZED);
|
|
|
e62044 |
@@ -991,7 +983,7 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
} else {
|
|
|
e62044 |
String existingValue = field.stringValue();
|
|
|
e62044 |
if (!indexField.equals(FIELD_PERSON) || !existingValue.contains(value)) {
|
|
|
e62044 |
- field.setValue(existingValue + " " + value); //$NON-NLS-1$
|
|
|
e62044 |
+ document.add(new StringField(field.name(), existingValue + " " + value, Store.YES)); //$NON-NLS-1$
|
|
|
e62044 |
}
|
|
|
e62044 |
}
|
|
|
e62044 |
}
|
|
|
e62044 |
@@ -1004,13 +996,13 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
// move the date by the GMT offset if there is any
|
|
|
e62044 |
|
|
|
e62044 |
String value = DateTools.dateToString(date, Resolution.HOUR);
|
|
|
e62044 |
- Field field = document.getField(indexField.getIndexKey());
|
|
|
e62044 |
+ IndexableField field = document.getField(indexField.getIndexKey());
|
|
|
e62044 |
if (field == null) {
|
|
|
e62044 |
field = new Field(indexField.getIndexKey(), value, Store.YES,
|
|
|
e62044 |
org.apache.lucene.document.Field.Index.ANALYZED);
|
|
|
e62044 |
document.add(field);
|
|
|
e62044 |
} else {
|
|
|
e62044 |
- field.setValue(value);
|
|
|
e62044 |
+ document.add(new StringField(field.name(), value, Store.YES));
|
|
|
e62044 |
}
|
|
|
e62044 |
}
|
|
|
e62044 |
|
|
|
e62044 |
@@ -1069,7 +1061,7 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
try {
|
|
|
e62044 |
if (!rebuildIndex) {
|
|
|
e62044 |
try {
|
|
|
e62044 |
- IndexReader reader = IndexReader.open(directory, false);
|
|
|
e62044 |
+ IndexReader reader = DirectoryReader.open(directory);
|
|
|
e62044 |
reader.close();
|
|
|
e62044 |
} catch (CorruptIndexException e) {
|
|
|
e62044 |
rebuildIndex = true;
|
|
|
e62044 |
@@ -1216,7 +1208,7 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
writer = createIndexWriter(true);
|
|
|
e62044 |
} catch (CorruptIndexException e) {
|
|
|
e62044 |
if (directory instanceof FSDirectory) {
|
|
|
e62044 |
- cleanDirectory(((FSDirectory) directory).getFile());
|
|
|
e62044 |
+ cleanDirectory(((FSDirectory) directory).getDirectory());
|
|
|
e62044 |
writer = createIndexWriter(true);
|
|
|
e62044 |
} else {
|
|
|
e62044 |
throw e;
|
|
|
e62044 |
@@ -1264,7 +1256,7 @@ public class TaskListIndex implements IT
|
|
|
e62044 |
|
|
|
e62044 |
protected IndexWriter createIndexWriter(boolean create) throws CorruptIndexException, LockObtainFailedException,
|
|
|
e62044 |
IOException {
|
|
|
e62044 |
- return new IndexWriter(directory, TaskAnalyzer.instance(), create, IndexWriter.MaxFieldLength.UNLIMITED);
|
|
|
e62044 |
+ return new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_CURRENT, TaskAnalyzer.instance()));
|
|
|
e62044 |
}
|
|
|
e62044 |
|
|
|
e62044 |
/**
|