Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into termvectors

  • Loading branch information...
commit 900997eb22a3cad3c4813a3cc7459b404f15eecc 2 parents 078bff8 + 453c434
@rnewson authored
View
9 pom.xml
@@ -185,6 +185,15 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.9</version>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <downloadJavadocs>true</downloadJavadocs>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
View
18 src/main/java/com/github/rnewson/couchdb/lucene/DatabaseIndexer.java
@@ -14,6 +14,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -40,8 +41,8 @@
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.document.MapFieldSelector;
import org.apache.lucene.document.NumericField;
+import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexReader.FieldOption;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogByteSizeMergePolicy;
@@ -60,6 +61,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.SingleInstanceLockFactory;
+import org.apache.lucene.util.ReaderUtil;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -285,7 +287,7 @@ public void admin(final HttpServletRequest req,
if ("_expunge".equals(command)) {
logger.info("Expunging deletes from " + state);
- state.writer.expungeDeletes(false);
+ state.writer.forceMergeDeletes(false);
resp.setStatus(202);
ServletUtils.sendJsonSuccess(req, resp);
return;
@@ -293,7 +295,7 @@ public void admin(final HttpServletRequest req,
if ("_optimize".equals(command)) {
logger.info("Optimizing " + state);
- state.writer.optimize(false);
+ state.writer.forceMerge(1, false);
resp.setStatus(202);
ServletUtils.sendJsonSuccess(req, resp);
return;
@@ -418,11 +420,15 @@ public void info(final HttpServletRequest req,
result.put("uuid", state.getUuid());
result.put("digest", state.getDigest());
final JSONArray fields = new JSONArray();
- for (final Object field : reader.getFieldNames(FieldOption.INDEXED)) {
- if (((String) field).startsWith("_")) {
+ final Iterator<FieldInfo> it = ReaderUtil.getMergedFieldInfos(reader).iterator();
+ while (it.hasNext()) {
+ final FieldInfo fieldInfo = it.next();
+ if (fieldInfo.name.startsWith("_")) {
continue;
}
- fields.put(field);
+ if (fieldInfo.isIndexed) {
+ fields.put(fieldInfo.name);
+ }
}
result.put("fields", fields);
result.put("last_modified", Long.toString(IndexReader
View
6 src/test/java/com/github/rnewson/couchdb/lucene/TikaTest.java
@@ -40,19 +40,19 @@ public void setup() {
@Test
public void testPDF() throws IOException {
parse("paxos-simple.pdf", "application/pdf", "foo");
- assertThat(doc.getField("foo"), not(nullValue()));
+ assertThat(doc.getFieldable("foo"), not(nullValue()));
}
@Test
public void testXML() throws IOException {
parse("example.xml", "text/xml", "bar");
- assertThat(doc.getField("bar"), not(nullValue()));
+ assertThat(doc.getFieldable("bar"), not(nullValue()));
}
@Test
public void testWord() throws IOException {
parse("example.doc", "application/msword", "bar");
- assertThat(doc.getField("bar"), not(nullValue()));
+ assertThat(doc.getFieldable("bar"), not(nullValue()));
assertThat(doc.get("bar"), containsString("The express mission of the organization"));
}
Please sign in to comment.
Something went wrong with that request. Please try again.