Examples of GetRequestBuilder


Examples of org.elasticsearch.action.get.GetRequestBuilder

    if (StringUtils.isBlank(key) || StringUtils.isBlank(appid)) {
      return map;
    }

    try {
      GetRequestBuilder grb = client().prepareGet().setIndex(appid).setId(key);

      if (type != null) {
        grb.setType(type);
      }

      map = grb.execute().actionGet().getSource();
    } catch (Exception e) {
      logger.warn(null, e);
    }
    return map;
  }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

        prepareNested();
        SearchIntoRequest request = new SearchIntoRequest("test");
        request.source("{\"fields\": [\"_id\", [\"x.city\", \"_source.city\"], [\"x.surname\", \"_source.name.surname\"], [\"x.name\", \"_source.name.name\"], [\"_index\", \"'newindex'\"]]}");
        SearchIntoResponse res = esSetup.client().execute(SearchIntoAction.INSTANCE, request).actionGet();

        GetRequestBuilder rb = new GetRequestBuilder(esSetup.client(), "newindex");
        GetResponse getRes = rb.setType("a").setId("1").execute().actionGet();
        assertTrue(getRes.isExists());
        assertEquals("{\"x\":{\"name\":\"Doe\",\"surname\":\"John\",\"city\":\"Dornbirn\"}}", getRes.getSourceAsString());
    }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

        assertNotNull(nodeInfo.get("node_id"));
        assertTrue(Long.valueOf(nodeInfo.get("took").toString()) > 0);
        assertTrue(nodeInfo.get("imported_files").toString().matches(
                "\\[\\{file_name=(.*)/importdata/import_4/import_4.json, successes=2, failures=0, invalidated=1}]"));

        GetRequestBuilder rb = new GetRequestBuilder(esSetup.client(), "test");
        GetResponse res = rb.setType("d").setId("402").setFields("_ttl", "_timestamp", "_routing").execute().actionGet();
        assertEquals("the_routing", res.getField("_routing").getValue());
        assertTrue(ttl - Long.valueOf(res.getField("_ttl").getValue().toString()) < 10000);
        assertEquals(1367329785380L, res.getField("_timestamp").getValue());

        res = rb.setType("d").setId("403").setFields("_ttl", "_timestamp").execute().actionGet();
        assertTrue(ttl - Long.valueOf(res.getField("_ttl").getValue().toString()) < 10000);
        assertTrue(now - Long.valueOf(res.getField("_timestamp").getValue().toString()) < 10000);

        assertFalse(existsWithField("404", "name", "404"));
    }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

    private boolean existsWithField(String id, String field, String value) {
        return existsWithField(id, field, value, "test", "d");
    }

    private boolean existsWithField(String id, String field, String value, String index, String type) {
        GetRequestBuilder rb = new GetRequestBuilder(esSetup.client(), index);
        GetResponse res = rb.setType(type).setId(id).execute().actionGet();
        return res.isExists() && res.getSourceAsMap().get(field).equals(value);
    }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

        assertEquals(0, metaData.numberOfReplicas());
    }


    private boolean existsWithField(String id, String field, String value, String index, String type) {
        GetRequestBuilder rb = new GetRequestBuilder(esSetup.client(), index);
        GetResponse res = rb.setType(type).setId(id).execute().actionGet();
        return res.isExists() && res.getSourceAsMap().get(field).equals(value);
    }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

     * @param indexPath
     * @param clazz
     * @return
     */
    public static <T extends Index> T get(IndexQueryPath indexPath, Class<T> clazz, String id) {
        GetRequestBuilder getRequestBuilder = getGetRequestBuilder(indexPath, id);
        GetResponse getResponse = getRequestBuilder.execute().actionGet();
        return getTFromGetResponse(clazz, getResponse);
    }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

     * @param id
     * @return
     */
    public static GetResponse get(String indexName, String indexType, String id) {

        GetRequestBuilder getRequestBuilder = IndexClient.client.prepareGet(indexName, indexType, id);
        GetResponse getResponse = getRequestBuilder.execute().actionGet();
        return getResponse;
    }
View Full Code Here

Examples of org.elasticsearch.action.get.GetRequestBuilder

    }

    // See if the index version exists and check if it matches. The request will
    // fail if there is no version index
    boolean versionIndexExists = false;
    GetRequestBuilder getRequestBuilder = nodeClient.prepareGet(site.getIdentifier(), VERSION_TYPE, ROOT_ID);
    try {
      GetResponse response = getRequestBuilder.execute().actionGet();
      if (response.exists() && response.field(VERSION) != null) {
        indexVersion = Integer.parseInt((String) response.field(VERSION).getValue());
        versionIndexExists = true;
        logger.debug("Search index version is {}", indexVersion);
      }
View Full Code Here

Examples of org.elasticsearch.client.action.get.GetRequestBuilder

    @Override public DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) {
        return new DeleteByQueryRequestBuilder(this).setIndices(indices);
    }

    @Override public GetRequestBuilder prepareGet() {
        return new GetRequestBuilder(this, null);
    }
View Full Code Here

Examples of org.elasticsearch.client.action.get.GetRequestBuilder

  // @param _id: the document primary key
  // @param sFields: the list of fields to return (can be null - will just return null if doc doesn't exist)
  // @returns: A map containing the requested fields (null if empty)
 
  public Map<String, GetField> getDocument(String _id, String... sFields) {
    GetRequestBuilder grb = _elasticClient.prepareGet(_sIndexName, _sIndexType, _id);
    if (null != sFields) {
      grb.setFields(sFields);
    }
    GetResponse gr = grb.execute().actionGet();
    Map<String, GetField> fieldsMap = gr.getFields();
    if (null != fieldsMap) {
      if (fieldsMap.isEmpty()) {
        fieldsMap = null;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.