Package org.elasticsearch.action.get

Examples of org.elasticsearch.action.get.GetResponse


    public Map<String, Object> getLocalDocument(String database, String docId) {
        return getDocumentElasticSearch(getElasticSearchIndexNameFromDatabase(database), docId, checkpointDocumentType);
    }

    protected Map<String, Object> getDocumentElasticSearch(String index, String docId, String docType) {
        GetResponse response = client.prepareGet(index, docType, docId).execute().actionGet();
        if(response != null && response.isExists()) {
            Map<String,Object> esDocument = response.getSourceAsMap();
            return (Map<String, Object>)esDocument.get("doc");
        }
        return null;
    }
View Full Code Here


        builder.setId(id);
        builder.setType(this.checkpointDocumentType);
        builder.setFetchSource(true);

        String bucketUUID = null;
        GetResponse response;
        ListenableActionFuture<GetResponse> laf = builder.execute();
        if(laf != null) {
            response = laf.actionGet();
            if(response.isExists()) {
            Map<String,Object> responseMap = response.getSourceAsMap();
            bucketUUID = this.getUUIDFromCheckpointDocSource(responseMap);
            }
        }

        return bucketUUID;
View Full Code Here

        builder.setId(id);
        builder.setType(this.checkpointDocumentType);
        builder.setFetchSource(true);

        String bucketUUID = null;
        GetResponse response;
        ListenableActionFuture<GetResponse> laf = builder.execute();
        if(laf != null) {
            response = laf.actionGet();
            if(response.isExists()) {
            Map<String,Object> responseMap = response.getSourceAsMap();
            bucketUUID = this.getUUIDFromCheckpointDocSource(responseMap);
            }
        }

        return bucketUUID;
View Full Code Here

        }
    }

    public MyTweet findById(Long twitterId) {
        try {
            GetResponse rsp = client.prepareGet(getIndexName(), getIndexType(), "" + twitterId).
                    execute().actionGet();
            return readDoc(rsp.getSource(), rsp.getId());
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

  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

    // TODO index the beer in meal index, beer type

    Assert.assertNotNull(ir);
    Assert.assertNotNull(ir.getId());

    GetResponse gr = null;
    // TODO get the beer we have just indexed

    Assert.assertNotNull(gr);
    Assert.assertNotNull(gr.getId());

    // We check that id are equals
    Assert.assertEquals(ir.getId(), gr.getId());

    Beer indexedBeer = null;
   
    // TODO Deserialize json indexed beer into a beer object

    Assert.assertNotNull(indexedBeer);
    Assert.assertEquals(beer, indexedBeer);

    // delete document
    DeleteResponse dr = null;
   
    // TODO Remove from elasticsearch the indexed beer

    Assert.assertNotNull(dr);
    Assert.assertTrue(dr.isFound());

    // TODO get the beer we have just removed

    Assert.assertNotNull(gr);
    // Beer should not exist anymore
    Assert.assertFalse(gr.isExists());

  }
View Full Code Here

    public JUser findByScreenName(String name) {
        try {
            name = name.toLowerCase();
            GetRequestBuilder grb = client.prepareGet(getIndexName(), getIndexType(), name);           
            GetResponse gr = grb.execute().actionGet();
            if (gr.isExists())
                return readDoc(gr.id(), gr.version(), gr.sourceAsMap());           
        } catch (Exception ex) {
            logger.error("Couldn't load user with screenName:" + name + " " + ex.getMessage());           
        }
        return null;
    }
View Full Code Here

        commitListener.remove(exec);
    }

    public JTweet findByTwitterId(Long twitterId) {
        try {
            GetResponse rsp = client.prepareGet(getIndexName(), getIndexType(), Long.toString(twitterId)).
                    execute().actionGet();
            if (rsp.getSource() == null)
                return null;
            return readDoc(rsp.getId(), rsp.getVersion(), rsp.getSource());
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

     * @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

     * @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

TOP

Related Classes of org.elasticsearch.action.get.GetResponse

Copyright © 2018 www.massapicom. 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.