org.elasticsearch.client.support.AbstractClient Java Examples

The following examples show how to use org.elasticsearch.client.support.AbstractClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticsearchConnection.java    From syncer with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.elasticsearch.transport.TcpTransport#TCP_CONNECT_TIMEOUT
 */
public AbstractClient esClient() throws Exception {
  // https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082
  System.setProperty("es.set.netty.runtime.available.processors", "false");

  TransportClient client = new PreBuiltXPackTransportClient(settings());
  for (String clusterNode : getClusterNodes()) {
    String hostName = substringBeforeLast(clusterNode, COLON);
    String port = substringAfterLast(clusterNode, COLON);
    Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
    Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
    logger.info("Adding transport node : {}, timeout in 30s", clusterNode);
    client.addTransportAddress(
        new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
  }
  return client;
}
 
Example #2
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void remoteCheck(AbstractClient client, List<Object> builderList) throws ExecutionException, InterruptedException {
  for (Object builder : builderList) {
    BulkRequestBuilder bulkRequestBuilder = null;
    if (builder instanceof IndexRequestBuilder) {
      bulkRequestBuilder = client.prepareBulk().add((IndexRequestBuilder) builder);
    } else if (builder instanceof UpdateRequestBuilder) {
      bulkRequestBuilder = client.prepareBulk().add((UpdateRequestBuilder) builder);
    }  else if (builder instanceof DeleteRequestBuilder) {
      bulkRequestBuilder = client.prepareBulk().add((DeleteRequestBuilder) builder);
    } else {
      fail();
    }
    BulkResponse bulkItemResponses = bulkRequestBuilder.execute().get();
    assertFalse(Arrays.stream(bulkItemResponses.getItems()).anyMatch(BulkItemResponse::isFailed));
  }
}
 
Example #3
Source File: ElasticsearchJavaAPIScriptTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
   * https://discuss.elastic.co/t/java-api-plainless-script-indexof-give-wrong-answer/139016/7
   */
  public static void scriptIndexOf() throws Exception {
    AbstractClient client = ElasticTestUtil.getDevClient();

    HashMap<String, Object> params = new HashMap<>();
    params.put("users", LONG_ID);
    Script add = new Script(ScriptType.INLINE, "painless",
        "ctx._source.users.add(params.users);",
        params);
    Script meta = new Script(ScriptType.INLINE, "painless",
        "ctx._source.t1 = params.users; ctx._source.i11= ctx._source.users.indexOf(params.users); ctx._source.i21= ctx._source.users.lastIndexOf(params.users);",
        params);
    Script remove = new Script(ScriptType.INLINE, "painless",
        "ctx._source.users.remove(ctx._source.users.indexOf(params.users));",
        params);

    BulkRequestBuilder bulkRequest = client.prepareBulk();
    bulkRequest.add(indexRequest(client, getSource()));
    bulkRequest.add(updateRequest(client, add));
    bulkRequest.add(updateRequest(client, meta));
    bulkRequest.add(updateRequest(client, remove));
    bulkRequest.add(updateRequest(client, meta));
    BulkResponse bulkItemResponses = bulkRequest.execute().actionGet();
    if (bulkItemResponses.hasFailures()) {
      for (BulkItemResponse itemResponse : bulkItemResponses.getItems()) {
        System.out.println(itemResponse.getFailure());
      }
//      Assert.fail();
    }
  }
 
Example #4
Source File: NodeTestUtils.java    From elasticsearch-analysis-baseform with Apache License 2.0 5 votes vote down vote up
private Node buildNode(String id) throws IOException {
    Settings nodeSettings = settingsBuilder()
            .put(getNodeSettings())
            .put("name", id)
            .build();
    logger.info("settings={}", nodeSettings.getAsMap());
    // ES 2.1 renders NodeBuilder as useless
    Node node = new MockNode(nodeSettings, AnalysisBaseformPlugin.class);
    AbstractClient client = (AbstractClient)node.client();
    nodes.put(id, node);
    clients.put(id, client);
    logger.info("clients={}", clients);
    return node;
}
 
Example #5
Source File: NodeTestUtils.java    From elasticsearch-analysis-baseform with Apache License 2.0 5 votes vote down vote up
private void closeNodes() throws IOException {
    logger.info("closing all clients");
    for (AbstractClient client : clients.values()) {
        client.close();
    }
    clients.clear();
    logger.info("closing all nodes");
    for (Node node : nodes.values()) {
        if (node != null) {
            node.close();
        }
    }
    nodes.clear();
    logger.info("all nodes closed");
}
 
Example #6
Source File: NodeTestUtils.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
private Node buildNode(String id) throws IOException {
    Settings nodeSettings = settingsBuilder()
            .put(getNodeSettings())
            .put("name", id)
            .build();
    logger.info("settings={}", nodeSettings.getAsMap());
    // ES 2.1 renders NodeBuilder as useless
    Node node = new MockNode(nodeSettings, HelperPlugin.class);
    AbstractClient client = (AbstractClient)node.client();
    nodes.put(id, node);
    clients.put(id, client);
    logger.info("clients={}", clients);
    return node;
}
 
Example #7
Source File: NodeTestUtils.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
private void closeNodes() throws IOException {
    logger.info("closing all clients");
    for (AbstractClient client : clients.values()) {
        client.close();
    }
    clients.clear();
    logger.info("closing all nodes");
    for (Node node : nodes.values()) {
        if (node != null) {
            node.close();
        }
    }
    nodes.clear();
    logger.info("all nodes closed");
}
 
Example #8
Source File: AbstractNodeTestHelper.java    From elasticsearch-csv with Apache License 2.0 5 votes vote down vote up
public void closeAllNodes() throws IOException {
    for (AbstractClient client : clients.values()) {
        client.close();
    }
    clients.clear();
    for (Node node : nodes.values()) {
        if (node != null) {
            node.close();
        }
    }
    nodes.clear();
}
 
Example #9
Source File: AbstractNodeTestHelper.java    From elasticsearch-csv with Apache License 2.0 5 votes vote down vote up
private Node buildNode(String id) {
    Settings finalSettings = settingsBuilder()
            .put(getNodeSettings())
            .put("name", id)
            .build();
    Node node = nodeBuilder()
            .settings(finalSettings).build();
    AbstractClient client = (AbstractClient)node.client();
    nodes.put(id, node);
    clients.put(id, client);
    return node;
}
 
Example #10
Source File: NodeTestUtils.java    From elasticsearch-xml with Apache License 2.0 5 votes vote down vote up
private Node buildNode(String id) throws IOException {
    Settings nodeSettings = settingsBuilder()
            .put(getNodeSettings())
            .put("name", id)
            .build();
    logger.info("settings={}", nodeSettings.getAsMap());
    // ES 2.1 renders NodeBuilder as useless
    Node node = new MockNode(nodeSettings, XmlPlugin.class);
    AbstractClient client = (AbstractClient)node.client();
    nodes.put(id, node);
    clients.put(id, client);
    logger.info("clients={}", clients);
    return node;
}
 
Example #11
Source File: NodeTestUtils.java    From elasticsearch-xml with Apache License 2.0 5 votes vote down vote up
private void closeNodes() throws IOException {
    logger.info("closing all clients");
    for (AbstractClient client : clients.values()) {
        client.close();
    }
    clients.clear();
    logger.info("closing all nodes");
    for (Node node : nodes.values()) {
        if (node != null) {
            node.close();
        }
    }
    nodes.clear();
    logger.info("all nodes closed");
}
 
Example #12
Source File: CompareDetail.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Map<String, Object> esDetail(AbstractClient client, String index, String type, int id) {
  SearchResponse response = client.prepareSearch(index).setTypes(type)
      .setQuery(QueryBuilders.termQuery("_id", id))
      .execute().actionGet();
  SearchHits hits = response.getHits();
  if (hits.totalHits == 0) {
    return Collections.emptyMap();
  }
  return hits.getAt(0).getSource();
}
 
Example #13
Source File: ElasticsearchJavaAPIScriptTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void scriptEqual() throws Exception {
    AbstractClient client = ElasticTestUtil.getDevClient();

    HashMap<String, Object> params = new HashMap<>();
    HashMap<String, Object> user0 = new HashMap<>();
    user0.put("id", LONG_ID);
    params.put("user0", user0);
    Script add = new Script(ScriptType.INLINE, "painless",
        "ctx._source.nested.add(params.user0);",
        params);

    params = new HashMap<>();
//    params.put("userId0", LONG_ID);
    params.put("userId0", EsTypeUtil.scriptConvert(LONG_ID));
    params.put("user0", user0);
    Script meta = new Script(ScriptType.INLINE, "painless",
        "if (ctx._source.nested == null) {ctx._source.nested = [];}if (ctx._source.nested.find(e -> e.id.equals(params.userId0)) == null) {\n" +
            "ctx._source.nested.add(params.user0);\n" +
            "}",
        params);

    BulkRequestBuilder bulkRequest = client.prepareBulk();
    bulkRequest.add(indexRequest(client, getSource()));
    bulkRequest.add(updateRequest(client, add));
    bulkRequest.add(updateRequest(client, meta));
    BulkResponse bulkItemResponses = bulkRequest.execute().actionGet();
    if (bulkItemResponses.hasFailures()) {
      for (BulkItemResponse itemResponse : bulkItemResponses.getItems()) {
        System.out.println(itemResponse.getFailure());
      }
//      Assert.fail();
    }
  }
 
Example #14
Source File: ElasticTestUtil.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static AbstractClient getDevClient() throws Exception {
  ElasticsearchConnection elasticsearchConnection = new ElasticsearchConnection();
  elasticsearchConnection.setClusterName("searcher-dev");
  elasticsearchConnection.setClusterNodes(Lists.newArrayList("58.213.85.37:9300"));

  return elasticsearchConnection.esClient();
}
 
Example #15
Source File: ElasticTestUtil.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static AbstractClient getIntClient() throws Exception {
  ElasticsearchConnection elasticsearchConnection = new ElasticsearchConnection();
  elasticsearchConnection.setClusterName("searcher-integration");
  elasticsearchConnection.setClusterNodes(Lists.newArrayList("192.168.1.100:9300"));

  return elasticsearchConnection.esClient();
}
 
Example #16
Source File: ESRequestMapper.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
ESRequestMapper(AbstractClient client, ESRequestMapping esRequestMapping) {
  this.esRequestMapping = esRequestMapping;
  this.client = client;
  SpelExpressionParser parser = new SpelExpressionParser();
  indexExpr = parser.parseExpression(esRequestMapping.getIndex());
  typeExpr = parser.parseExpression(esRequestMapping.getType());

  esQueryMapper = new ESQueryMapper(client);
  requestBodyMapper = new KVMapper(esRequestMapping.getFieldsMapping());
}
 
Example #17
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static List<Object> innerMergeToList() throws Exception {
  List<Object> res = new ArrayList<>();

  AbstractClient client = ElasticTestUtil.getDevClient();
  Elasticsearch elasticsearch = new Elasticsearch();
  ESRequestMapper mapper = new ESRequestMapper(client, elasticsearch.getRequestMapping());

  SyncData data = SyncDataTestUtil.write("list", "list");
  data.addField("roles", new ArrayList<>());
  Object builder = mapper.map(data);
  assertEquals("", "index {[list][list][1234], source[{\"roles\":[]}]}",
      ((IndexRequestBuilder) builder).request().toString());
  res.add(builder);


  data = SyncDataTestUtil.write("list", "list");
  data.addField("role", 1381034L);
  data.addField("test_id", 1234L);
  data.esScriptUpdate(Filter.id("test_id")).mergeToList("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[list][list][1234], script[Script{type=inline, lang='painless', idOrCode='ctx._source.roles.add(params.roles);', options={}, params={roles=1381034}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);


  data = SyncDataTestUtil.delete("list", "list");
  data.addField("role", 1381034L);
  data.addField("test_id", 1234L);
  data.esScriptUpdate(Filter.id("test_id")).mergeToList("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[list][list][1234], script[Script{type=inline, lang='painless', idOrCode='ctx._source.roles.removeIf(Predicate.isEqual(params.roles));', options={}, params={roles=1381034}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  return res;
}
 
Example #18
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static List<Object> innerMergeToListById() throws Exception {
  List<Object> res = new ArrayList<>();

  AbstractClient client = ElasticTestUtil.getDevClient();
  Elasticsearch elasticsearch = new Elasticsearch();
  ESRequestMapper mapper = new ESRequestMapper(client, elasticsearch.getRequestMapping());

  SyncData data = SyncDataTestUtil.write();
  data.addField("roles" + BY_ID_SUFFIX, new ArrayList<>());
  data.addField("roles", new ArrayList<>());
  Object builder = mapper.map(data);
  res.add(builder);

  data = SyncDataTestUtil.write();
  data.addField("role", 1381034L);
  data.addField("test_id", 1234L);
  data.esScriptUpdate(Filter.id("test_id")).mergeToListById("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[test][test][1234], script[Script{type=inline, lang='painless', idOrCode='if (!ctx._source.roles_id.contains(params.roles_id)) {ctx._source.roles_id.add(params.roles_id); ctx._source.roles.add(params.roles); }', options={}, params={roles_id=1234, roles=1381034}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  data = SyncDataTestUtil.delete();
  data.addField("role", 13276746L);
  data.addField("test_id", 1234L);
  data.esScriptUpdate(Filter.id("test_id")).mergeToListById("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[test][test][1234], script[Script{type=inline, lang='painless', idOrCode='if (ctx._source.roles_id.removeIf(Predicate.isEqual(params.roles_id))) {ctx._source.roles.removeIf(Predicate.isEqual(params.roles)); }', options={}, params={roles_id=1234, roles=13276746}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  return res;
}
 
Example #19
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static List<Object> innerNestedByParentId() throws Exception {
  List<Object> res = new ArrayList<>();

  AbstractClient client = ElasticTestUtil.getDevClient();
  Elasticsearch elasticsearch = new Elasticsearch();
  ESRequestMapper mapper = new ESRequestMapper(client, elasticsearch.getRequestMapping());

  SyncData data = SyncDataTestUtil.write("nested", "nested");
  data.setId(1L);
  data.addField("roles", new ArrayList<>());
  Object builder = mapper.map(data);
  res.add(builder);

  data = SyncDataTestUtil.write("nested", "nested");
  data.addField("role", 1381034L);
  data.addField("ann_id", 1L);
  data.esScriptUpdate(Filter.id("ann_id")).mergeToNestedById("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[nested][nested][1], script[Script{type=inline, lang='painless', idOrCode='if (ctx._source.roles.find(e -> e.id.equals(params.id)) == null) {  ctx._source.roles.add(params.roles);}', options={}, params={id=1234, roles={role=1381034, id=1234}}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  data = SyncDataTestUtil.write("nested", "nested");
  data.addField("role", 2381034L).addField("ann_id", 1L).setId(2345);
  data.esScriptUpdate(Filter.id("ann_id")).mergeToNestedById("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[nested][nested][1], script[Script{type=inline, lang='painless', idOrCode='if (ctx._source.roles.find(e -> e.id.equals(params.id)) == null) {  ctx._source.roles.add(params.roles);}', options={}, params={id=2345, roles={role=2381034, id=2345}}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  data = SyncDataTestUtil.update("nested", "nested");
  data.getBefore().put("role", 1381034L);
  data.addField("role", 13276746L);
  data.addField("ann_id", 1L);
  data.esScriptUpdate(Filter.id("ann_id")).mergeToNestedById("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[nested][nested][1], script[Script{type=inline, lang='painless', idOrCode='def target = ctx._source.roles.find(e -> e.id.equals(params.id));if (target != null) { target.role = params.role;}', options={}, params={role=13276746, id=1234}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  data = SyncDataTestUtil.delete("nested", "nested");
  data.addField("role", 13276746L).addField("ann_id", 1L).setId(2345L);
  data.esScriptUpdate(Filter.id("ann_id")).mergeToNestedById("roles", "role");

  builder = mapper.map(data);
  assertEquals("", "update {[nested][nested][1], script[Script{type=inline, lang='painless', idOrCode='ctx._source.roles.removeIf(e -> e.id.equals(params.id)); ', options={}, params={id=2345}}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  return res;
}
 
Example #20
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static void mergeToListRemote() throws Exception {
  AbstractClient client = ElasticTestUtil.getDevClient();
  remoteCheck(client, innerMergeToList());
}
 
Example #21
Source File: NodeTestUtils.java    From elasticsearch-analysis-baseform with Apache License 2.0 4 votes vote down vote up
public AbstractClient client(String id) {
    return clients.get(id);
}
 
Example #22
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static void mergeToListByIdRemote() throws Exception {
  AbstractClient client = ElasticTestUtil.getDevClient();
  remoteCheck(client, innerMergeToListById());
}
 
Example #23
Source File: NodeTestUtils.java    From elasticsearch-helper with Apache License 2.0 4 votes vote down vote up
public AbstractClient client(String id) {
    return clients.get(id);
}
 
Example #24
Source File: AbstractNodeTestHelper.java    From elasticsearch-csv with Apache License 2.0 4 votes vote down vote up
public AbstractClient client(String id) {
    return clients.get(id);
}
 
Example #25
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void nestedWithExtraQuery() throws Exception {
  AbstractClient client = ElasticTestUtil.getDevClient();
  Elasticsearch elasticsearch = new Elasticsearch();
  ESRequestMapper mapper = new ESRequestMapper(client, elasticsearch.getRequestMapping());

  SyncData data = SyncDataTestUtil.update("role", "role").setId(1234L);
  data.setRepo("nested3").setEntity("nested3").addField("title", "b").addField("user_id", 2L);
  data.extraQuery("user", "user").filter("_id", -1L).select("username").addField("username");
  data.esScriptUpdate(Filter.fieldId("roles.id")).mergeToNestedById("roles", "title", "user_id", "username");

  Object builder = mapper.map(data);
  assertEquals("", "{\n" +
          "  \"size\" : 1000,\n" +
          "  \"query\" : {\n" +
          "    \"bool\" : {\n" +
          "      \"filter\" : [\n" +
          "        {\n" +
          "          \"nested\" : {\n" +
          "            \"query\" : {\n" +
          "              \"bool\" : {\n" +
          "                \"filter\" : [\n" +
          "                  {\n" +
          "                    \"term\" : {\n" +
          "                      \"roles.id\" : {\n" +
          "                        \"value\" : 1234,\n" +
          "                        \"boost\" : 1.0\n" +
          "                      }\n" +
          "                    }\n" +
          "                  }\n" +
          "                ],\n" +
          "                \"disable_coord\" : false,\n" +
          "                \"adjust_pure_negative\" : true,\n" +
          "                \"boost\" : 1.0\n" +
          "              }\n" +
          "            },\n" +
          "            \"path\" : \"roles\",\n" +
          "            \"ignore_unmapped\" : false,\n" +
          "            \"score_mode\" : \"avg\",\n" +
          "            \"boost\" : 1.0\n" +
          "          }\n" +
          "        }\n" +
          "      ],\n" +
          "      \"disable_coord\" : false,\n" +
          "      \"adjust_pure_negative\" : true,\n" +
          "      \"boost\" : 1.0\n" +
          "    }\n" +
          "  }\n" +
          "}",
      ((AbstractBulkByScrollRequestBuilder)builder).source().toString());
  assertEquals("", "update-by-query [nested3] updated with Script{type=inline, lang='painless', idOrCode='def target = ctx._source.roles.find(e -> e.id.equals(params.id));if (target != null) { target.user_id = params.user_id;target.title = params.title;target.username = params.username;}', options={}, params={id=1234, title=b, user_id=2, username=null}}",
      ((UpdateByQueryRequestBuilder) builder).request().toString());
}
 
Example #26
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static List<Object> innerSetFieldNull() throws Exception {
  List<Object> res = new ArrayList<>();

  AbstractClient client = ElasticTestUtil.getDevClient();
  Elasticsearch elasticsearch = new Elasticsearch();
  ESRequestMapper mapper = new ESRequestMapper(client, elasticsearch.getRequestMapping());

  SyncData data = SyncDataTestUtil.write();
  data.addField("list", Lists.newArrayList(1)).addField("int", 1).addField("str", "1");
  Object builder = mapper.map(data);
  assertEquals("", "index {[test][test][1234], source[{\"str\":\"1\",\"list\":[1],\"int\":1}]}",
      ((IndexRequestBuilder) builder).request().toString());
  res.add(builder);

  data = SyncDataTestUtil.update();
  data.setFieldNull("int").setFieldNull("str").setFieldNull("list");

  builder = mapper.map(data);
  assertEquals("", "update {[test][test][1234], doc[index {[null][null][null], source[{\"str\":null,\"list\":null,\"int\":null}]}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  data = SyncDataTestUtil.update();
  data.addField("int", 1381034L).addField("str", "1234").addField("list", Lists.newArrayList(2));

  builder = mapper.map(data);
  assertEquals("", "update {[test][test][1234], doc[index {[null][null][null], source[{\"str\":\"1234\",\"list\":[2],\"int\":1381034}]}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);


  data = SyncDataTestUtil.update();
  data.setFieldNull("int").setFieldNull("str").setFieldNull("list");

  builder = mapper.map(data);
  assertEquals("", "update {[test][test][1234], doc[index {[null][null][null], source[{\"str\":null,\"list\":null,\"int\":null}]}], detect_noop[true]}",
      ElasticsearchChannel.toString(((UpdateRequestBuilder) builder).request()));
  res.add(builder);

  return res;
}
 
Example #27
Source File: NodeTestUtils.java    From elasticsearch-xml with Apache License 2.0 4 votes vote down vote up
public AbstractClient client(String id) {
    return clients.get(id);
}
 
Example #28
Source File: CompareDetail.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private AbstractClient getAbstractClient() throws Exception {
  ElasticsearchConnection elasticsearchConnection = new ElasticsearchConnection();
  elasticsearchConnection.setClusterName("test-cluster");
  elasticsearchConnection.setClusterNodes(Lists.newArrayList("192.168.1.249:49300"));
  return elasticsearchConnection.esClient();
}
 
Example #29
Source File: ESRequestMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void setFieldNullRemote() throws Exception {
  AbstractClient client = ElasticTestUtil.getDevClient();
  remoteCheck(client, innerSetFieldNull());
}
 
Example #30
Source File: ElasticsearchJavaAPIScriptTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static IndexRequest indexRequest(AbstractClient client, Map<String, Object> source) {
  return client.prepareIndex("test", "test", "1").setSource(source).request();
}