Search in sources :

Example 31 with BatchSearch

use of org.icij.datashare.batch.BatchSearch in project datashare by ICIJ.

the class BatchSearchRunnerIntTest method test_search_phrase_matches_with_slop.

@Test
public void test_search_phrase_matches_with_slop() throws Exception {
    // with phrase match a permutation (they call it transposition) is 2 slop
    // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html
    Document mydoc = createDoc("docId").with("mydoc find").build();
    indexer.add(TEST_INDEX, mydoc);
    BatchSearch search = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("find mydoc"), User.local(), false, null, null, 2, true);
    new BatchSearchRunner(indexer, new PropertiesProvider(), search, resultConsumer).call();
    verify(resultConsumer).apply(search.uuid, "find mydoc", singletonList(mydoc));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) Document(org.icij.datashare.text.Document)

Example 32 with BatchSearch

use of org.icij.datashare.batch.BatchSearch in project datashare by ICIJ.

the class BatchSearchRunnerIntTest method test_search_with_file_types_ko.

@Test
public void test_search_with_file_types_ko() throws Exception {
    Document mydoc = createDoc("mydoc").build();
    indexer.add(TEST_INDEX, mydoc);
    BatchSearch searchKo = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("mydoc"), User.local(), false, singletonList("application/pdf"), null, 0);
    new BatchSearchRunner(indexer, new PropertiesProvider(), searchKo, resultConsumer).call();
    verify(resultConsumer, never()).apply(eq(searchKo.uuid), eq("mydoc"), anyList());
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) Document(org.icij.datashare.text.Document)

Aggregations

BatchSearch (org.icij.datashare.batch.BatchSearch)32 PropertiesProvider (org.icij.datashare.PropertiesProvider)18 Test (org.junit.Test)17 Document (org.icij.datashare.text.Document)15 AbstractProdWebServerTest (org.icij.datashare.web.testhelpers.AbstractProdWebServerTest)9 Date (java.util.Date)6 Response (net.codestory.rest.Response)4 BatchSearchRepository (org.icij.datashare.batch.BatchSearchRepository)4 SearchException (org.icij.datashare.batch.SearchException)4 JooqBatchSearchRepository (org.icij.datashare.db.JooqBatchSearchRepository)4 User (org.icij.datashare.user.User)4 CollectionUtils.asSet (org.icij.datashare.CollectionUtils.asSet)3 SearchResult (org.icij.datashare.batch.SearchResult)3 Project.project (org.icij.datashare.text.Project.project)3 HashMap (java.util.HashMap)2 List (java.util.List)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Collectors (java.util.stream.Collectors)2 IntStream (java.util.stream.IntStream)2 NotFoundException (net.codestory.http.errors.NotFoundException)2