use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method testLuceneWithNonFullText.
@Test
public void testLuceneWithNonFullText() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
NodeBuilder nb = newLuceneIndexDefinitionV2(index, "lucene", of(TYPENAME_STRING));
nb.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false);
nb.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo", "price", "weight", "bool", "creationTime"), STRINGS));
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, nb.getNodeState(), "/foo");
NodeState before = builder.getNodeState();
builder.child("test").setProperty("foo", "fox is jumping");
builder.child("test").setProperty("bar", "kite is flying");
builder.child("test").setProperty("price", 100);
builder.child("test").setProperty("weight", 10.0);
builder.child("test").setProperty("bool", true);
builder.child("test").setProperty("truth", true);
builder.child("test").setProperty("creationTime", createCal("05/06/2014"));
NodeState after = builder.getNodeState();
NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
tracker.update(indexed);
assertNull("Fulltext search should not work", query("foo:fox", defn));
assertEquals("/test", getPath(new TermQuery(new Term("foo", "fox is jumping"))));
assertNull("bar must NOT be indexed", getPath(new TermQuery(new Term("bar", "kite is flying"))));
// Long
assertEquals("/test", getPath(NumericRangeQuery.newDoubleRange("weight", 8D, 12D, true, true)));
// Double
assertEquals("/test", getPath(NumericRangeQuery.newLongRange("price", 100L, 100L, true, true)));
// Boolean
assertEquals("/test", getPath(new TermQuery(new Term("bool", "true"))));
assertNull("truth must NOT be indexed", getPath(new TermQuery(new Term("truth", "true"))));
// Date
assertEquals("/test", getPath(NumericRangeQuery.newLongRange("creationTime", dateToTime("05/05/2014"), dateToTime("05/07/2014"), true, true)));
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method numDocs.
private int numDocs(Mount m) throws IOException {
String indexDirName = MultiplexersLucene.getIndexDirName(m);
NodeBuilder defnBuilder = builder.child(INDEX_DEFINITIONS_NAME).child("lucene");
Directory d = new OakDirectory(defnBuilder, indexDirName, new LuceneIndexDefinition(root, defnBuilder.getNodeState(), "/foo"), true);
IndexReader r = DirectoryReader.open(d);
return r.numDocs();
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition in project jackrabbit-oak by apache.
the class DefaultIndexWriterTest method indexUpdated.
@Test
public void indexUpdated() throws Exception {
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo");
DefaultIndexWriter writer = createWriter(defn, false);
Document document = new Document();
document.add(newPathField("/a/b"));
writer.updateDocument("/a/b", document);
assertTrue(writer.close(0));
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition in project jackrabbit-oak by apache.
the class DefaultIndexWriterTest method writeInitializedUponReindex.
@Test
public void writeInitializedUponReindex() throws Exception {
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo");
DefaultIndexWriter writer = createWriter(defn, true);
assertTrue(writer.close(0));
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition in project jackrabbit-oak by apache.
the class DefaultIndexWriterTest method indexWriterConfig_Scheduler_Remote.
@Test
public void indexWriterConfig_Scheduler_Remote() throws Exception {
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo");
DefaultIndexWriter writer = createWriter(defn, true);
IndexWriter w = writer.getWriter();
assertThat(w.getConfig().getMergeScheduler(), instanceOf(SerialMergeScheduler.class));
}
Aggregations