Package org.elasticsearch.search

Examples of org.elasticsearch.search.SearchHits


                                                                                                 * "*"
                                                                                                 * )
                                                                                                 */
            .setTypes(metadata.getTableName()).setQuery(QueryBuilders.termQuery(colName, colValue)).execute().get();

            SearchHits hits = response.getHits();
            for (SearchHit hit : hits)
            {
                MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                        metadata.getPersistenceUnit());

View Full Code Here


        );
        assertTrue(
                client().admin().indices().prepareAliasesExist("parted")
                        .execute().actionGet().exists()
        );
        SearchHits hits = client().prepareSearch(partitionName.stringValue())
                .setTypes(Constants.DEFAULT_MAPPING_TYPE)
                .addFields("id", "name")
                .setQuery(new MapBuilder<String, Object>()
                                .put("match_all", new HashMap<String, Object>())
                                .map()
                ).execute().actionGet().getHits();
        assertThat(hits.getTotalHits(), is(1L));
        assertThat((Integer) hits.getHits()[0].field("id").getValues().get(0), is(0));
        assertThat((String)hits.getHits()[0].field("name").getValues().get(0), is("Trillian"));
    }
View Full Code Here

    List<P> list = new ArrayList<P>();
    if (ids == null || ids.isEmpty()) {
      return list;
    }
    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()));
View Full Code Here

    // find nearby Address objects
    QueryBuilder qb1 = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
        FilterBuilders.geoDistanceFilter("latlng").point(lat, lng).
        distance(radius, DistanceUnit.KILOMETERS));

    SearchHits hits1 = searchQueryRaw(appid, Utils.type(Address.class), qb1, pager);

    if (hits1 == null) {
      return new ArrayList<P>();
    }

    // then find their parent objects
    String[] ridsarr = new String[(int) hits1.getTotalHits()];
    for (int i = 0; i < hits1.getTotalHits(); i++) {
      Object pid = hits1.getAt(i).getSource().get(Config._PARENTID);
      if (pid != null) {
        ridsarr[i] = pid.toString();
      }
    }

    QueryBuilder qb2 = QueryBuilders.filteredQuery(QueryBuilders.queryString(query),
        FilterBuilders.idsFilter(type).ids(ridsarr));
    SearchHits hits2 = searchQueryRaw(appid, type, qb2, pager);

    return searchQuery(appid, hits2);
  }
View Full Code Here

    }
    if (type == null) {
      type = "_all";
    }

    SearchHits hits = null;

    try {
      SearchResponse response = client().prepareSearch(appid).
          setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setTypes(type).
          setQuery(query).addSort(sort).setFrom(start).setSize(max).
          execute().actionGet();

      hits = response.getHits();
      page.setCount(hits.getTotalHits());
    } catch (Exception e) {
      logger.warn(null, e);
    }

    return hits;
View Full Code Here

        }
   
        protected SearchResponse filterMaxHits(SearchResponse response, int maxHits) {
            // We will use internal APIs here for efficiency. The plugin has restricted explicit ES compatibility
            // anyway. Alternatively, we could serialize/ filter/ deserialize JSON, but this seems simpler.
            SearchHits allHits  = response.getHits();
            InternalSearchHit [] trimmedHits = new InternalSearchHit[Math.min(maxHits, allHits.hits().length)];
            System.arraycopy(allHits.hits(), 0, trimmedHits, 0, trimmedHits.length);

            InternalFacets facets = null;
            if (response.getFacets() != null) {
                facets = new InternalFacets(response.getFacets().facets());
            }

            InternalAggregations aggregations = null;
            if (response.getAggregations() != null) {
                aggregations = new InternalAggregations(toInternal(response.getAggregations().asList()));
            }

            return new SearchResponse(
                    new InternalSearchResponse(
                            new InternalSearchHits(trimmedHits, allHits.getTotalHits(), allHits.getMaxScore()),
                            facets,
                            aggregations,
                            response.getSuggest(),
                            response.isTimedOut()),
                    response.getScrollId(),
View Full Code Here

        Assertions.assertThat(result.getDocumentGroups())
            .isNotNull()
            .isNotEmpty();

        Map<String,SearchHit> idToHit = Maps.newHashMap();
        SearchHits hits = result.getSearchResponse().getHits();
        if (hits != null) {
            for (SearchHit hit : hits) {
                idToHit.put(hit.getId(), hit);
            }
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.SearchHits

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.