Search in sources :

Example 6 with IndexDocument

use of com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument in project xp by enonic.

the class NodeIndexDocumentFactoryTest method index_node_document_created.

@Test
public void index_node_document_created() throws Exception {
    Node node = Node.create().id(NodeId.from("abc")).build();
    final Collection<IndexDocument> indexDocuments = NodeStoreDocumentFactory.createBuilder().node(node).branch(TEST_BRANCH).repositoryId(TEST_REPOSITORY_ID).build().create();
    assertNotNull(indexDocuments);
    assertNotNull(getIndexDocumentOfType(indexDocuments, "test"));
}
Also used : IndexDocument(com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 7 with IndexDocument

use of com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument in project xp by enonic.

the class StoreDocumentXContentBuilderFactoryTest method testName.

@Test
public void testName() throws Exception {
    final IndexItems indexItems = IndexItems.create().add(IndexPath.from("myProperty"), ValueFactory.newString("myValue"), createDefaultDocument(IndexConfig.MINIMAL)).build();
    final IndexDocument indexDocument = IndexDocument.create().analyzer("myAnalyzer").id(NodeId.from("myNodeId").toString()).indexName("myIndex").indexTypeName("myIndexType").indexItems(indexItems).build();
    final XContentBuilder xContentBuilder = StoreDocumentXContentBuilderFactory.create(indexDocument);
    System.out.println(xContentBuilder.string());
}
Also used : IndexDocument(com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument) IndexItems(com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItems) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.jupiter.api.Test)

Example 8 with IndexDocument

use of com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument in project xp by enonic.

the class NodeIndexDocumentFactoryTest method node_index_document_meta_data_values.

@Test
public void node_index_document_meta_data_values() throws Exception {
    final String myAnalyzerName = "myAnalyzer";
    Node node = Node.create().id(NodeId.from("myId")).parentPath(NodePath.ROOT).name(NodeName.from("my-name")).indexConfigDocument(PatternIndexConfigDocument.create().analyzer(myAnalyzerName).defaultConfig(IndexConfig.MINIMAL).build()).build();
    final Collection<IndexDocument> indexDocuments = NodeStoreDocumentFactory.createBuilder().node(node).branch(TEST_BRANCH).repositoryId(TEST_REPOSITORY_ID).build().create();
    final IndexDocument indexDocument = getIndexDocumentOfType(indexDocuments, "test");
    assertEquals(myAnalyzerName, indexDocument.getAnalyzer());
    assertEquals(IndexNameResolver.resolveSearchIndexName(TEST_REPOSITORY_ID), indexDocument.getIndexName());
    assertEquals("test", indexDocument.getIndexTypeName());
}
Also used : IndexDocument(com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Aggregations

IndexDocument (com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument)8 Test (org.junit.jupiter.api.Test)6 Node (com.enonic.xp.node.Node)5 IndexItems (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItems)2 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)2 PropertyTree (com.enonic.xp.data.PropertyTree)1 IndexConfigDocument (com.enonic.xp.index.IndexConfigDocument)1 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)1 IndexValue (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValue)1 IndexValueString (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValueString)1 IndexException (com.enonic.xp.repository.IndexException)1 Reference (com.enonic.xp.util.Reference)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1