- private static ElasticSearchHttpController elasticSearch;
- private static AAIEntityTestObject testDocument;
-
- private static final String indexMappings = "{\r\n \"properties\": {\r\n \"entityType\": {\r\n \"type\": \"string\"\r\n },\r\n \"edgeTagQueryEntityFieldName\": {\r\n \"type\": \"string\",\r\n \"index\": \"no\"\r\n },\r\n \"edgeTagQueryEntityFieldValue\": {\r\n \"type\": \"string\",\r\n \"index\": \"no\"\r\n },\r\n \"searchTagIDs\" : {\r\n \"type\" : \"string\"\r\n },\r\n \"searchTags\": {\r\n \"type\": \"string\",\r\n \"analyzer\": \"nGram_analyzer\",\r\n \"search_analyzer\": \"whitespace_analyzer\"\r\n }\r\n }\r\n}";
- private static final String indexSettings = "{\r\n \"analysis\": {\r\n \"filter\": {\r\n \"nGram_filter\": {\r\n \"type\": \"nGram\",\r\n \"min_gram\": 1,\r\n \"max_gram\": 50,\r\n \"token_chars\": [\r\n \"letter\",\r\n \"digit\",\r\n \"punctuation\",\r\n \"symbol\"\r\n ]\r\n }\r\n },\r\n \"analyzer\": {\r\n \"nGram_analyzer\": {\r\n \"type\": \"custom\",\r\n \"tokenizer\": \"whitespace\",\r\n \"filter\": [\r\n \"lowercase\",\r\n \"asciifolding\",\r\n \"nGram_filter\"\r\n ]\r\n },\r\n \"whitespace_analyzer\": {\r\n \"type\": \"custom\",\r\n \"tokenizer\": \"whitespace\",\r\n \"filter\": [\r\n \"lowercase\",\r\n \"asciifolding\"\r\n ]\r\n }\r\n }\r\n }\r\n}";
-
- @Before
- public void setUp() throws Exception {
- Properties properties = new Properties();
- properties.put(ElasticSearchConfig.ES_IP_ADDRESS, "127.0.0.1");
- properties.put(ElasticSearchConfig.ES_HTTP_PORT, "9200");
-// ElasticSearchConfig config = new ElasticSearchConfig(properties);
- ElasticSearchConfig config = new ElasticSearchConfig(properties);
- elasticSearch = new ElasticSearchHttpController(config);
-
- testDocument = new AAIEntityTestObject();
- testDocument.setId("test123");
- testDocument.setEntityType("service-instance");
- testDocument.setEdgeTagQueryEntityFieldName("service-instance.service-instance-id");
- testDocument.setEdgeTagQueryEntityFieldValue("123456");
- testDocument.setSearchTagIDs("0");
- testDocument.setSearchTags("service-instance-id");
-
- }
-//
- @Test
- public void testCreateTable() throws Exception {
- OperationResult result = elasticSearch.createTable("test", "aai-entities", indexSettings, indexMappings);
- System.out.println(result);
- }
-
- @Test
- public void testsuggestionQueryWithPayload() throws Exception {
- Assert.assertNotNull(elasticSearch.suggestionQueryWithPayload("autoSuggest", "suggest-index"));
- }
-//
- @Test
- public void testCreateDocument() throws Exception {
- OperationResult result = elasticSearch.createDocument("test", testDocument, false);
- System.out.println(result);
-
- DocumentStoreDataEntityImpl ds = new DocumentStoreDataEntityImpl();
- ds.setId(testDocument.getId());
-
- result = elasticSearch.getDocument("test", ds);
- System.out.println(result);
- }
-
- @Test
- public void testUpdateDocument() throws Exception {
- testDocument.setEdgeTagQueryEntityFieldValue("567890");
-
- OperationResult result = elasticSearch.updateDocument("test", testDocument, false);
- System.out.println(result);
-
- result = elasticSearch.getDocument("test", testDocument);
- System.out.println(result);
- }
-
- @Test
- public void testDeleteDocument() throws Exception {
- OperationResult result = elasticSearch.deleteDocument("test", testDocument);
- System.out.println(result);
-
- result = elasticSearch.getDocument("test", testDocument);
- System.out.println(result);
- }
-
- @Test
- public void testBulkCreateDocuments() throws Exception {
- for (int i = 0; i < 10; i++) {
- AAIEntityTestObject doc = new AAIEntityTestObject();
- doc.setId("test-" + i);
- doc.setEntityType("service-instance");
- doc.setEdgeTagQueryEntityFieldName("service-instance.service-instance-id");
- doc.setEdgeTagQueryEntityFieldValue("123456" + i);
- doc.setSearchTagIDs("" + i);
- doc.setSearchTags("service-instance-id");