我正在尝试使用 ElasticSearch,所以我构建了一个简单的 JUnit 测试,但测试需要 5 秒才能运行,我认为这很慢。不知道我是否错过了什么?
Node node = NodeBuilder.nodeBuilder().node();
Client client = node.client();
BulkRequestBuilder brb = client.prepareBulk();
Map<String, Object> json = new HashMap<>();
Map<String, Object> nest = new HashMap<>();
nest.put("foo", "blah");
json.put("Code", "123");
json.put("nut", nest);
json.put("images", newArrayList("image1", "image2"));
brb.add(new IndexRequest("promotions", "promotion").source(json));
brb.execute().actionGet();
MatchQueryBuilder itemNumber = QueryBuilders.matchQuery("Code", "123");
SearchResponse sr = client.prepareSearch("promotions").setTypes("promotion").setQuery(itemNumber).execute().actionGet();
assertThat((List)sr.getHits().getHits()[0].getSource().get("images")).contains("image1");
assertThat((List)sr.getHits().getHits()[0].getSource().get("images")).contains("image2");
assertThat((List)sr.getHits().getHits()[0].getSource().get("images")).doesNotContain("image3");