use of org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class ElasticIndexerTest method nodeIndexed_WithIncludedPaths.
@Test
public void nodeIndexed_WithIncludedPaths() throws Exception {
ElasticIndexDefinitionBuilder idxb = new ElasticIndexDefinitionBuilder();
idxb.indexRule("nt:base").property("foo").propertyIndex();
idxb.includedPaths("/content");
NodeState defn = idxb.build();
IndexDefinition idxDefn = new ElasticIndexDefinition(root, defn, "/oak:index/testIndex", "testPrefix");
NodeBuilder builder = root.builder();
FulltextIndexWriter indexWriter = new ElasticIndexWriterFactory(mock(ElasticConnection.class), mock(ElasticIndexTracker.class)).newInstance(idxDefn, defn.builder(), CommitInfo.EMPTY, false);
ElasticIndexer indexer = new ElasticIndexer(idxDefn, mock(FulltextBinaryTextExtractor.class), builder, mock(IndexingProgressReporter.class), indexWriter, mock(ElasticIndexEditorProvider.class), mock(IndexHelper.class));
NodeState testNode = EMPTY_NODE.builder().setProperty("foo", "bar").getNodeState();
assertTrue(indexer.index(new NodeStateEntry.NodeStateEntryBuilder(testNode, "/content/x").build()));
assertFalse(indexer.index(new NodeStateEntry.NodeStateEntryBuilder(testNode, "/x").build()));
assertFalse(indexer.index(new NodeStateEntry.NodeStateEntryBuilder(testNode, "/").build()));
}
use of org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class ElasticReindexTest method reindex.
@Test
public void reindex() throws Exception {
IndexDefinitionBuilder indexDefinitionBuilder = new ElasticIndexDefinitionBuilder();
indexDefinitionBuilder.noAsync();
IndexDefinitionBuilder.IndexRule indexRule = indexDefinitionBuilder.indexRule("nt:base");
indexRule.property("a").propertyIndex().analyzed();
String indexName = UUID.randomUUID().toString();
indexDefinitionBuilder.build(adminSession.getRootNode().getNode(INDEX_DEFINITIONS_NAME).addNode(indexName, INDEX_DEFINITIONS_NODE_TYPE));
adminSession.save();
Node content = adminSession.getRootNode().addNode("content");
for (int i = 0; i < 100; i++) {
Node c = content.addNode("c_" + i);
c.setProperty("a", "foo");
c.setProperty("b", "bar");
}
adminSession.save();
assertQuery("select [jcr:path] from [nt:base] where contains(a, 'foo')", 100);
// adding an extra content node (handled by reindex and potentially incremental indexing)
Node c = content.addNode("c_100");
c.setProperty("a", "foo");
c.setProperty("b", "bar");
Node indexNode = adminSession.getRootNode().getNode(INDEX_DEFINITIONS_NAME).getNode(indexName);
Node b = indexNode.getNode("indexRules").getNode("nt:base").getNode("properties").addNode("b");
b.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true);
b.setProperty(FulltextIndexConstants.PROP_ANALYZED, true);
// Now we reindex and see everything works fine
indexNode.setProperty(REINDEX_PROPERTY_NAME, true);
adminSession.save();
assertQuery("select [jcr:path] from [nt:base] where contains(b, 'bar')", 101);
}
use of org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class ElasticIndexHelperTest method oakAnalyzerWithOriginalTerm.
@Test
public void oakAnalyzerWithOriginalTerm() throws IOException {
IndexDefinitionBuilder builder = new ElasticIndexDefinitionBuilder();
IndexDefinitionBuilder.IndexRule indexRule = builder.indexRule("type");
indexRule.property("foo").type("String").analyzed();
Tree analyzer = builder.getBuilderTree().addChild("analyzers");
analyzer.setProperty("indexOriginalTerm", "true");
NodeState nodeState = builder.build();
ElasticIndexDefinition definition = new ElasticIndexDefinition(nodeState, nodeState, "path", "prefix");
CreateIndexRequest request = ElasticIndexHelper.createIndexRequest("prefix.path", definition);
assertThat(request.settings().get("analysis.filter.oak_word_delimiter_graph_filter.preserve_original"), is("true"));
}
use of org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class ElasticAbstractQueryTest method createIndex.
protected IndexDefinitionBuilder createIndex(boolean isPropertyIndex, String nodeType, String... propNames) {
IndexDefinitionBuilder builder = new ElasticIndexDefinitionBuilder();
if (!useAsyncIndexing()) {
builder = builder.noAsync();
}
IndexDefinitionBuilder.IndexRule indexRule = builder.indexRule(nodeType);
if (isPropertyIndex) {
for (String propName : propNames) {
indexRule.property(propName).propertyIndex();
}
}
return builder;
}
use of org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class ElasticDocumentMakerLargeStringPropertiesLogTest method addPropertyAccordingToType.
private ElasticDocumentMaker addPropertyAccordingToType(NodeBuilder test, Type type, String... str) throws IOException {
NodeState root = INITIAL_CONTENT;
ElasticIndexDefinitionBuilder builder = new ElasticIndexDefinitionBuilder();
builder.indexRule("nt:base").property("foo").propertyIndex().analyzed().valueExcludedPrefixes("/jobs");
IndexDefinition defn = ElasticIndexDefinition.newBuilder(root, builder.build(), "/foo").build();
ElasticDocumentMaker docMaker = new ElasticDocumentMaker(null, defn, defn.getApplicableIndexingRule("nt:base"), "/x");
if (Type.STRINGS == type) {
test.setProperty("foo", asList(str), Type.STRINGS);
} else if (Type.STRING == type && str.length == 1) {
test.setProperty("foo", str[0]);
} else {
throw new InvalidParameterException();
}
return docMaker;
}
Aggregations