Package org.elasticsearch.action.get

Examples of org.elasticsearch.action.get.GetResponse


    if (logger.isDebugEnabled())
      logger.debug("Going to read datetime value from {} property for project {}. Document name is {}.", propertyName,
          projectKey, documentName);

    refreshSearchIndex(getRiverIndexName());
    GetResponse lastSeqGetResponse = client.prepareGet(getRiverIndexName(), riverName.name(), documentName).execute()
        .actionGet();
    if (lastSeqGetResponse.isExists()) {
      Object timestamp = lastSeqGetResponse.getSourceAsMap().get(STORE_FIELD_VALUE);
      if (timestamp != null) {
        lastDate = DateTimeUtils.parseISODateTime(timestamp.toString());
      }
    } else {
      if (logger.isDebugEnabled())
View Full Code Here


    }
    try {
      SearchHits hits = null;
      MultiGetResponse response = client().prepareMultiGet().add(appid, null, ids).execute().actionGet();
      for (MultiGetItemResponse multiGetItemResponse : response.getResponses()) {
        GetResponse res = multiGetItemResponse.getResponse();
        if (res.isExists() && !res.isSourceEmpty()) {
          list.add(Utils.setAnnotatedFields(res.getSource()));
        }
      }
    } catch (Exception e) {
      logger.warn(null, e);
    }
View Full Code Here

    }
    if (StringUtils.isBlank(type)) {
      type = "_all";
    }
    try {
      GetResponse resp = client().prepareGet().setIndex(appid).
          setId(key).setType(type).execute().actionGet();
      map = resp.getSource();
    } catch (Exception e) {
      logger.warn(null, e);
    }
    return map;
  }
View Full Code Here

    // Action
    entityDao.save(node);
    refresh(INDEX_NAME);

    // Assert
    GetResponse response = client().prepareGet(INDEX_NAME, "node", "1").execute().actionGet();
    Assert.assertTrue(response.isExists());
    String expected = "{\"centroid\":[2.0,1.0],\"shape\":{\"type\":\"point\",\"coordinates\":[2.0,1.0]},\"tags\":{\"highway\":\"traffic_signals\"}}";
    String actual = response.getSourceAsString();
    Assert.assertEquals(expected, actual);
  }
View Full Code Here

    // Action
    entityDao.save(way);
    refresh(INDEX_NAME);

    // Assert
    GetResponse response = client().prepareGet(INDEX_NAME, "way", "1").execute().actionGet();
    Assert.assertTrue(response.isExists());
    String expected = "{\"centroid\":[2.3333333333333335,2.0],\"lengthKm\":536.8973391277414," +
        "\"areaKm2\":12364.345757132623,\"shape\":{\"type\":\"polygon\",\"coordinates\":" +
        "[[[2.0,1.0],[3.0,2.0],[2.0,3.0],[2.0,1.0]]]},\"tags\":{\"highway\":\"residential\"}}";
    String actual = response.getSourceAsString();
    Assert.assertEquals(expected, actual);
  }
View Full Code Here

    // Action
    entityDao.save(way);
    refresh(INDEX_NAME);

    // Assert
    GetResponse response = client().prepareGet(INDEX_NAME, "way", "1").execute().actionGet();
    Assert.assertTrue(response.isExists());
    String expected = "{\"centroid\":[2.1666666666666665,2.5],\"lengthKm\":471.76076948850596," +
        "\"areaKm2\":0.0,\"shape\":{\"type\":\"linestring\",\"coordinates\":" +
        "[[2.0,1.0],[3.0,2.0],[2.0,3.0],[1.0,4.0]]},\"tags\":{\"highway\":\"residential\"}}";
    String actual = response.getSourceAsString();
    Assert.assertEquals(expected, actual);
  }
View Full Code Here

    // Assert
    String expected = "{\"centroid\":[2.0,1.0],\"shape\":{\"type\":\"point\",\"coordinates\":[2.0,1.0]}," +
        "\"tags\":{\"highway\":\"traffic_signals\"}}";

    GetResponse response1 = client().prepareGet(INDEX_NAME, "node", "1").execute().actionGet();
    Assert.assertTrue(response1.isExists());
    String actual1 = response1.getSourceAsString();
    Assert.assertEquals(expected, actual1);

    GetResponse response2 = client().prepareGet(INDEX_NAME, "node", "2").execute().actionGet();
    Assert.assertTrue(response2.isExists());
    String actual2 = response2.getSourceAsString();
    Assert.assertEquals(expected, actual2);
  }
View Full Code Here

  }

  @Test
  public void buildFromGetReponse() {
    // Setup
    GetResponse response = mock(GetResponse.class, Mockito.RETURNS_DEEP_STUBS);
    when(response.getType()).thenReturn(ESEntityType.NODE.getIndiceName());
    when(response.getId()).thenReturn("1");
    Map<String, String> tags = new HashMap<String, String>();
    tags.put("highway", "primary");
    when(response.getField("tags").getValue()).thenReturn(tags);
    List<Double> location = Arrays.asList(new Double[] { 2.0, 1.0 });
    @SuppressWarnings("unchecked")
    Map<String, Object> shape = mock(Map.class);
    when(shape.get("coordinates")).thenReturn(location);
    when(response.getField("shape").getValue()).thenReturn(shape);

    ESNode expected = ESNode.Builder.create().id(1l).location(1.0, 2.0)
        .addTag("highway", "primary").build();

    // Action
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void buildFromGetReponse_withInvalidGetResponse() {
    // Setup
    GetResponse response = mock(GetResponse.class, Mockito.RETURNS_DEEP_STUBS);
    when(response.getType()).thenReturn(ESEntityType.WAY.getIndiceName());

    // Action
    ESNode.Builder.buildFromGetReponse(response);
  }
View Full Code Here

  }

  @Test
  public void buildFromGetReponse() {
    // Setup
    GetResponse response = mock(GetResponse.class, Mockito.RETURNS_DEEP_STUBS);
    when(response.getType()).thenReturn(ESEntityType.WAY.getIndiceName());
    when(response.getId()).thenReturn("1");
    Map<String, String> tags = new HashMap<String, String>();
    tags.put("highway", "primary");
    when(response.getField("tags").getValue()).thenReturn(tags);
    List<List<List<Double>>> locations = new ArrayList<List<List<Double>>>();
    ArrayList<List<Double>> subLocations = new ArrayList<List<Double>>();
    subLocations.add(Arrays.asList(new Double[] { 2.0, 1.0 }));
    subLocations.add(Arrays.asList(new Double[] { 3.0, 2.0 }));
    locations.add(subLocations);
    @SuppressWarnings("unchecked")
    Map<String, Object> shape = mock(Map.class);
    when(shape.get("type")).thenReturn("polygon");
    when(shape.get("coordinates")).thenReturn(locations);
    when(response.getField("shape").getValue()).thenReturn(shape);
    when(response.getField("centroid").getValue()).thenReturn(Arrays.asList(new Double[] { 2.5, 1.5 }));
    when(response.getField("lengthKm").getValue()).thenReturn(157.25358982950198d);
    when(response.getField("areaKm2").getValue()).thenReturn(0d);

    ESWay expected = ESWay.Builder.create().id(1l)
        .addLocation(1.0, 2.0).addLocation(2.0, 3.0)
        .addTag("highway", "primary").build();
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.