Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchResponse


        LOG.debug("[{}] Starting scroll request for query {}", queryHash, getOriginalQuery());
    }

    public ScrollChunk nextChunk() {
        final SearchResponse search = client.prepareSearchScroll(scrollId)
                .setScroll(TimeValue.timeValueMinutes(1))
                .execute()
                .actionGet();

        final SearchHits hits = search.getHits();
        if (hits.getHits().length == 0) {
            // scroll exhausted
            LOG.debug("[{}] Reached end of scroll results.", queryHash, getOriginalQuery());
            return null;
        }
        LOG.debug("[{}] New scroll id {}", queryHash, search.getScrollId());
        scrollId = search.getScrollId(); // save the id for the next request.

        return new ScrollChunk(hits, fields, chunkId++);
    }
View Full Code Here


    }

    public void move(String source, String target) {
        QueryBuilder qb = matchAllQuery();

        SearchResponse scrollResp = c.prepareSearch(source)
                .setSearchType(SearchType.SCAN)
                .setScroll(new TimeValue(10000))
                .setQuery(qb)
                .setSize(350).execute().actionGet();

        while (true) {
            scrollResp = c.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();

            // No more hits.
            if (scrollResp.getHits().hits().length == 0) {
                break;
            }

            final BulkRequestBuilder request = c.prepareBulk();
            for (SearchHit hit : scrollResp.getHits()) {
                Map<String, Object> doc = hit.getSource();
                String id = (String) doc.remove("_id");

                request.add(manualIndexRequest(target, doc, id).request());
            }
View Full Code Here

                                    if (searchSourceBuilder != null) {
                                        searchRequest.extraSource(searchSourceBuilder);
                                    }

                                    SearchResponse searchResponse = searchAction.execute(searchRequest).get();
                                    viewContext.queriesAndHits(queryName, searchResponse.hits());

                                } catch (Exception e) {
                                    viewContext.queriesAndHits(queryName, null);
                                }
                            }
View Full Code Here

            if (idx_resultField != null && !"_source".equals(idx_resultField)) {
              req.addField(mappingRecord.get(CFG_idx_result_field));
            }
          }

          SearchResponse resp = req.execute().actionGet();

          if (resp.getHits().getTotalHits() > 0) {
            if (resp.getHits().getTotalHits() > 1) {
              String message = "More results found during lookup for value '" + sourceValue + "' using index field '"
                  + idxSf;
              if (ignoreMultipleResults)
                message += "', so we ignore them.";
              else
                message += "', so first one is used.";

              addDataWarning(chainContext, message);
              logger.debug(message);
              if (ignoreMultipleResults) {
                continue;
              }
            }
            SearchHit hit = resp.getHits().hits()[0];
            for (Map<String, String> mappingRecord : resultMapping) {
              String idx_resultField = mappingRecord.get(CFG_idx_result_field);
              Object v = null;
              SearchHitField shf = null;
              if ("_source".equals(idx_resultField)) {
View Full Code Here

  protected SpaceIndexingInfo getLastSpaceIndexingInfo(String spaceKey) {
    SpaceIndexingInfo lastIndexing = lastSpaceIndexingInfo.get(spaceKey);
    if (lastIndexing == null && activityLogIndexName != null) {
      try {
        refreshSearchIndex(activityLogIndexName);
        SearchResponse sr = client.prepareSearch(activityLogIndexName).setTypes(activityLogTypeName)
            .setPostFilter(FilterBuilders.termFilter(SpaceIndexingInfo.DOCFIELD_SPACE_KEY, spaceKey))
            .setQuery(QueryBuilders.matchAllQuery()).addSort(SpaceIndexingInfo.DOCFIELD_START_DATE, SortOrder.DESC)
            .addField("_source").setSize(1).execute().actionGet();
        if (sr.getHits().getTotalHits() > 0) {
          SearchHit hit = sr.getHits().getAt(0);
          lastIndexing = SpaceIndexingInfo.readFromDocument(hit.sourceAsMap());
        } else {
          logger.debug("No last indexing info found in activity log for space {}", spaceKey);
        }
      } catch (Exception e) {
View Full Code Here

    logger.debug("go to delete indexed issues for space {} not updated after {}", spaceKey, boundDate);
    SearchRequestBuilder srb = esIntegrationComponent.prepareESScrollSearchRequestBuilder(indexName);
    documentIndexStructureBuilder.buildSearchForIndexedDocumentsNotUpdatedAfter(srb, spaceKey, boundDate);

    SearchResponse scrollResp = esIntegrationComponent.executeESSearchRequest(srb);

    if (scrollResp.getHits().getTotalHits() > 0) {
      if (isClosed())
        throw new InterruptedException("Interrupted because River is closed");
      scrollResp = esIntegrationComponent.executeESScrollSearchNextRequest(scrollResp);
      BulkRequestBuilder esBulk = esIntegrationComponent.prepareESBulkRequestBuilder();
      while (scrollResp.getHits().getHits().length > 0) {
        for (SearchHit hit : scrollResp.getHits()) {
          logger.debug("Go to delete indexed document for ES document id {}", hit.getId());
          if (documentIndexStructureBuilder.deleteESDocument(esBulk, hit)) {
            indexingInfo.documentsDeleted++;
          } else {
            indexingInfo.commentsDeleted++;
View Full Code Here

  protected ProjectIndexingInfo getLastProjectIndexingInfo(String projectKey) {
    ProjectIndexingInfo lastIndexing = lastProjectIndexingInfo.get(projectKey);
    if (lastIndexing == null && activityLogIndexName != null) {
      try {
        refreshSearchIndex(activityLogIndexName);
        SearchResponse sr = client.prepareSearch(activityLogIndexName).setTypes(activityLogTypeName)
            .setPostFilter(FilterBuilders.termFilter(ProjectIndexingInfo.DOCFIELD_PROJECT_KEY, projectKey))
            .setQuery(QueryBuilders.matchAllQuery()).addSort(ProjectIndexingInfo.DOCFIELD_START_DATE, SortOrder.DESC)
            .addField("_source").setSize(1).execute().actionGet();
        if (sr.getHits().getTotalHits() > 0) {
          SearchHit hit = sr.getHits().getAt(0);
          lastIndexing = ProjectIndexingInfo.readFromDocument(hit.sourceAsMap());
        } else {
          logger.debug("No last indexing info found in activity log for project {}", projectKey);
        }
      } catch (Exception e) {
View Full Code Here

    logger.debug("go to delete indexed issues for project {} not updated after {}", projectKey, boundDate);
    SearchRequestBuilder srb = esIntegrationComponent.prepareESScrollSearchRequestBuilder(indexName);
    jiraIssueIndexStructureBuilder.buildSearchForIndexedDocumentsNotUpdatedAfter(srb, projectKey, boundDate);

    SearchResponse scrollResp = esIntegrationComponent.executeESSearchRequest(srb);

    if (scrollResp.getHits().getTotalHits() > 0) {
      if (isClosed())
        throw new InterruptedException("Interrupted because River is closed");
      scrollResp = esIntegrationComponent.executeESScrollSearchNextRequest(scrollResp);
      BulkRequestBuilder esBulk = esIntegrationComponent.prepareESBulkRequestBuilder();
      while (scrollResp.getHits().getHits().length > 0) {
        for (SearchHit hit : scrollResp.getHits()) {
          logger.debug("Go to delete indexed issue for document id {}", hit.getId());
          if (jiraIssueIndexStructureBuilder.deleteIssueDocument(esBulk, hit)) {
            indexingInfo.issuesDeleted++;
          } else {
            indexingInfo.commentsDeleted++;
View Full Code Here

  protected SpaceIndexingInfo getLastSpaceIndexingInfo(String spaceKey) {
    SpaceIndexingInfo lastIndexing = lastSpaceIndexingInfo.get(spaceKey);
    if (lastIndexing == null && activityLogIndexName != null) {
      try {
        refreshSearchIndex(activityLogIndexName);
        SearchResponse sr = client.prepareSearch(activityLogIndexName).setTypes(activityLogTypeName)
            .setPostFilter(FilterBuilders.termFilter(SpaceIndexingInfo.DOCFIELD_SPACE_KEY, spaceKey))
            .setQuery(QueryBuilders.matchAllQuery()).addSort(SpaceIndexingInfo.DOCFIELD_START_DATE, SortOrder.DESC)
            .addField("_source").setSize(1).execute().actionGet();
        if (sr.getHits().getTotalHits() > 0) {
          SearchHit hit = sr.getHits().getAt(0);
          lastIndexing = SpaceIndexingInfo.readFromDocument(hit.sourceAsMap());
        } else {
          logger.debug("No last indexing info found in activity log for space {}", spaceKey);
        }
      } catch (Exception e) {
View Full Code Here

    logger.debug("go to delete indexed issues for space {} not updated after {}", spaceKey, boundDate);
    SearchRequestBuilder srb = esIntegrationComponent.prepareESScrollSearchRequestBuilder(indexName);
    documentIndexStructureBuilder.buildSearchForIndexedDocumentsNotUpdatedAfter(srb, spaceKey, boundDate);

    SearchResponse scrollResp = esIntegrationComponent.executeESSearchRequest(srb);

    if (scrollResp.getHits().getTotalHits() > 0) {
      if (isClosed())
        throw new InterruptedException("Interrupted because River is closed");
      scrollResp = esIntegrationComponent.executeESScrollSearchNextRequest(scrollResp);
      BulkRequestBuilder esBulk = esIntegrationComponent.prepareESBulkRequestBuilder();
      while (scrollResp.getHits().getHits().length > 0) {
        for (SearchHit hit : scrollResp.getHits()) {
          logger.debug("Go to delete indexed document for ES document id {}", hit.getId());
          if (documentIndexStructureBuilder.deleteESDocument(esBulk, hit)) {
            indexingInfo.documentsDeleted++;
          } else {
            indexingInfo.commentsDeleted++;
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.search.SearchResponse

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.