Search in sources :

Example 1 with ElasticsearchSpewer

use of org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer in project datashare by ICIJ.

the class IndexerHelper method indexEmbeddedFile.

File indexEmbeddedFile(String project, String docPath) throws IOException {
    Path path = get(getClass().getResource(docPath).getPath());
    Extractor extractor = new Extractor(new DocumentFactory().withIdentifier(new DigestIdentifier("SHA-384", Charset.defaultCharset())));
    extractor.setDigester(new UpdatableDigester(project, Entity.HASHER.toString()));
    TikaDocument document = extractor.extract(path);
    ElasticsearchSpewer elasticsearchSpewer = new ElasticsearchSpewer(client, l -> ENGLISH, new FieldNames(), mock(Publisher.class), new PropertiesProvider()).withRefresh(IMMEDIATE).withIndex("test-datashare");
    elasticsearchSpewer.write(document);
    return path.toFile();
}
Also used : Path(java.nio.file.Path) PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) DocumentFactory(org.icij.extract.document.DocumentFactory) UpdatableDigester(org.icij.extract.extractor.UpdatableDigester) FieldNames(org.icij.spewer.FieldNames) DigestIdentifier(org.icij.extract.document.DigestIdentifier) TikaDocument(org.icij.extract.document.TikaDocument) Extractor(org.icij.extract.extractor.Extractor) Publisher(org.icij.datashare.com.Publisher)

Example 2 with ElasticsearchSpewer

use of org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer in project datashare by ICIJ.

the class IndexTaskTest method test_index_task_null_user_uses_options_for_index_name.

@Test
public void test_index_task_null_user_uses_options_for_index_name() {
    ElasticsearchSpewer spewer = mock(ElasticsearchSpewer.class);
    new IndexTask(spewer, mock(Publisher.class), mock(DocumentCollectionFactory.class), nullUser(), "queueName", new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
            put("defaultProject", "foo");
        }
    }).getProperties());
    Mockito.verify(spewer).withIndex("foo");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) Publisher(org.icij.datashare.com.Publisher) Test(org.junit.Test)

Example 3 with ElasticsearchSpewer

use of org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer in project datashare by ICIJ.

the class IndexTaskTest method test_index_task_uses_users_index_name.

@Test
public void test_index_task_uses_users_index_name() {
    ElasticsearchSpewer spewer = mock(ElasticsearchSpewer.class);
    new IndexTask(spewer, mock(Publisher.class), mock(DocumentCollectionFactory.class), local(), "queueName", new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
        }
    }).getProperties());
    Mockito.verify(spewer).withIndex("local-datashare");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) Publisher(org.icij.datashare.com.Publisher) Test(org.junit.Test)

Example 4 with ElasticsearchSpewer

use of org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer in project datashare by ICIJ.

the class IndexTaskTest method test_index_task_with_null_user_and_null_index_name.

@Test
public void test_index_task_with_null_user_and_null_index_name() {
    ElasticsearchSpewer spewer = mock(ElasticsearchSpewer.class);
    new IndexTask(spewer, mock(Publisher.class), mock(DocumentCollectionFactory.class), local(), "queueName", new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
        }
    }).getProperties());
    Mockito.verify(spewer).withIndex("local-datashare");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) Publisher(org.icij.datashare.com.Publisher) Test(org.junit.Test)

Aggregations

PropertiesProvider (org.icij.datashare.PropertiesProvider)4 Publisher (org.icij.datashare.com.Publisher)4 ElasticsearchSpewer (org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer)4 Test (org.junit.Test)3 Path (java.nio.file.Path)1 DigestIdentifier (org.icij.extract.document.DigestIdentifier)1 DocumentFactory (org.icij.extract.document.DocumentFactory)1 TikaDocument (org.icij.extract.document.TikaDocument)1 Extractor (org.icij.extract.extractor.Extractor)1 UpdatableDigester (org.icij.extract.extractor.UpdatableDigester)1 FieldNames (org.icij.spewer.FieldNames)1