@SuppressWarnings("unchecked") @Test public void testMetadata() throws Exception { createMetadataDocument(); ae.process(jCas); elasticsearch.flush(BALEEN_INDEX); assertEquals(new Long(1), getCount()); SearchHit result = elasticsearch.client().search(new SearchRequest()).actionGet().getHits().getHits()[0]; List<String> pids = (List<String>) result.getSource().get("publishedId"); assertEquals("id_1", pids.get(0)); assertEquals("id_2", pids.get(1)); Map<String, Object> metadataMap = (Map<String, Object>) result.getSource().get("metadata"); assertEquals("D3", metadataMap.get("sourceAndInformationGrading")); assertEquals("test_value", metadataMap.get("test_key")); assertEquals("Test Title", metadataMap.get("documentTitle")); assertEquals("ENG|WAL|SCO", metadataMap.get("countryInfo")); }
ae.process(jCas); elasticsearch.flush(BALEEN_INDEX);
@SuppressWarnings("unchecked") @Test public void testNoEntities() throws Exception { long timestamp = createNoEntitiesDocument(); ae.process(jCas); elasticsearch.flush(BALEEN_INDEX); assertEquals(new Long(1), getCount()); SearchHit result = elasticsearch.client().search(new SearchRequest()).actionGet().getHits().getHits()[0]; assertEquals("Hello World", result.getSource().get("content")); assertEquals("en", result.getSource().get("language")); assertEquals(timestamp, result.getSource().get("dateAccessed")); assertEquals("test/no_entities", result.getSource().get("sourceUri")); assertEquals("test", result.getSource().get(DOC_TYPE)); assertEquals("OFFICIAL", result.getSource().get("classification")); List<String> rels = (List<String>) result.getSource().get("releasability"); assertEquals(3, rels.size()); assertTrue(rels.contains("ENG")); List<String> cavs = (List<String>) result.getSource().get("caveats"); assertEquals(2, cavs.size()); assertTrue(cavs.contains("TEST_A")); }
elasticsearch.flush(BALEEN_INDEX);
elasticsearch.flush(TEMPORAL_INDEX);
elasticsearch.flush(TEMPORAL_INDEX);
elasticsearch.flush(LOCATION_INDEX);
@Test public void testReindexEntities() throws Exception { createEntitiesDocument(); ae.process(jCas); ae.process(jCas); // Change the last document so we can check its been updated getDocumentAnnotation(jCas).setDocumentClassification("TEST"); ae.process(jCas); elasticsearch.flush(BALEEN_INDEX); assertEquals(new Long(1), getCount()); SearchHit result = elasticsearch.client().search(new SearchRequest()).actionGet().getHits().getHits()[0]; // This checks the last document is tone we are getting assertEquals("TEST", result.getSource().get("classification")); }
@Test public void test() throws AnalysisEngineProcessException { final AnalysisMockData data = new AnalysisMockData(); ae.process(data.getJCas()); elasticsearch.flush(Elasticsearch.DEFAULT_DOCUMENT_INDEX); assertEquals(1, countTypeInIndex(Elasticsearch.DEFAULT_DOCUMENT_TYPE)); assertEquals(4, countTypeInIndex(Elasticsearch.DEFAULT_ENTITY_TYPE)); assertEquals(2, countTypeInIndex(Elasticsearch.DEFAULT_RELATION_TYPE)); assertEquals(5, countTypeInIndex(Elasticsearch.DEFAULT_MENTION_TYPE)); } }
@Test public void testNestedEntities() throws Exception { createEntitiesDocument(); ae.process(jCas); createEntitiesDocument2(); ae.process(jCas); elasticsearch.flush(BALEEN_INDEX); assertEquals(new Long(2), getCount()); SearchRequestBuilder srb = elasticsearch .client() .prepareSearch(BALEEN_INDEX) .setQuery( QueryBuilders.nestedQuery( "entities", QueryBuilders.boolQuery() .must(QueryBuilders.matchQuery("entities.type", "Location")) .must(QueryBuilders.matchQuery("entities.value", "London")), ScoreMode.Avg)); SearchHits results = elasticsearch.client().search(srb.request()).actionGet().getHits(); assertEquals(1, results.getTotalHits()); }