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();
}
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");
}
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");
}
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");
}
Aggregations