Examples of SearchResponse


Examples of org.elasticsearch.action.search.SearchResponse

    }

    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

Examples of org.elasticsearch.action.search.SearchResponse

                                    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

Examples of org.elasticsearch.action.search.SearchResponse

            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

Examples of org.elasticsearch.action.search.SearchResponse

  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

Examples of org.elasticsearch.action.search.SearchResponse

    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

Examples of org.graylog2.rest.resources.search.responses.SearchResponse

        return result;
    }

    protected SearchResponse buildSearchResponse(SearchResult sr, TimeRange timeRange) {
        SearchResponse result = new SearchResponse();
        result.query = sr.getOriginalQuery();
        result.builtQuery = sr.getBuiltQuery();
        result.usedIndices = sr.getUsedIndices();
        result.messages = sr.getResults();
        result.fields = sr.getFields();
View Full Code Here

Examples of org.graylog2.rest.resources.search.responses.SearchResponse

            }
            Throwable rootCause = ((SearchParseException) unwrapped).getRootCause();
            if (rootCause instanceof ParseException) {

                Token currentToken = ((ParseException) rootCause).currentToken;
                SearchResponse sr = new SearchResponse();
                sr.query = query;
                sr.error = new QueryParseError();
                if (currentToken == null) {
                    LOG.warn("No position/token available for ParseException.");
                } else {
                    // scan for first usable token with position information
                    while (currentToken != null && sr.error.beginLine == 0) {
                        sr.error.beginColumn = currentToken.beginColumn;
                        sr.error.beginLine = currentToken.beginLine;
                        sr.error.endColumn = currentToken.endColumn;
                        sr.error.endLine = currentToken.endLine;

                        currentToken = currentToken.next;
                    }
                }
                return new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(json(sr)).build());
            } else if(rootCause instanceof NumberFormatException) {
                final SearchResponse sr = new SearchResponse();
                sr.query = query;
                sr.genericError = new GenericError();
                sr.genericError.exceptionName = rootCause.getClass().getCanonicalName();
                sr.genericError.message = rootCause.getMessage();
                return new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(json(sr)).build());
            } else {
                LOG.info("Root cause of SearchParseException has unexpected, generic type!" + rootCause.getClass());
                final SearchResponse sr = new SearchResponse();
                sr.query = query;
                sr.genericError = new GenericError();
                sr.genericError.exceptionName = rootCause.getClass().getCanonicalName();
                sr.genericError.message = rootCause.getMessage();
                return new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(json(sr)).build());
View Full Code Here

Examples of org.jahia.services.search.SearchResponse

    /* (non-Javadoc)
     * @see org.jahia.services.search.SearchProvider#search(org.jahia.services.search.SearchCriteria, org.jahia.params.ProcessingContext)
     */
    public SearchResponse search(SearchCriteria criteria, RenderContext context) {
        SearchResponse response = new SearchResponse();

        List<Hit<?>> results = new LinkedList<Hit<?>>();
        Set<String> addedHits = new HashSet<String>();
        Set<String> addedNodes = new HashSet<String>();
        try {
            JCRSessionWrapper session = ServicesRegistry
                    .getInstance()
                    .getJCRStoreService()
                    .getSessionFactory()
                    .getCurrentUserSession(context.getMainResource().getWorkspace(),
                            context.getMainResource().getLocale(), context.getFallbackLocale());
            Query query = buildQuery(criteria, session);
            if (query != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Executing search query [{}]", query.getStatement());
                }
                QueryResult queryResult = query.execute();
                RowIterator it = queryResult.getRows();
                Set<String> languages = new HashSet<String>();
                if (it.hasNext()) {
                    if (!criteria.getLanguages().isEmpty()) {
                        for (String languageCode : criteria.getLanguages().getValues()) {
                            if (!StringUtils.isEmpty(languageCode)) {
                                languages.add(languageCode);
                            }
                        }
                    } else {
                        if (session.getLocale() != null) {
                            languages.add(session.getLocale().toString());
                        }
                    }
                }

                while (it.hasNext()) {
                    try {
                        Row row = it.nextRow();
                        JCRNodeWrapper node = (JCRNodeWrapper) row.getNode();
                        if (node.isNodeType(Constants.JAHIANT_TRANSLATION)
                                || Constants.JCR_CONTENT.equals(node.getName())) {
                            node = node.getParent();
                        }
                        if (addedNodes.add(node.getIdentifier()) && !isNodeToSkip(node, criteria, languages)) {
                            Hit<?> hit = buildHit(row, node, context);

                            SearchServiceImpl.executeURLModificationRules(hit, context);

                            if (addedHits.add(hit.getLink())) {
                                results.add(hit);
                            }
                        }
                    } catch (Exception e) {
                        logger.warn("Error resolving search hit", e);
                    }
                }
            }
        } catch (RepositoryException e) {
            if (e.getMessage() != null && e.getMessage().contains(ParseException.class.getName())) {
                logger.warn(e.getMessage());
                if (logger.isDebugEnabled()) {
                    logger.debug(e.getMessage(), e);
                }
            } else {
                logger.error("Error while trying to perform a search", e);
            }
        } catch (Exception e) {
            logger.error("Error while trying to perform a search", e);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Search query has {} results", results.size());
        }
        response.setResults(results);

        return response;
    }
View Full Code Here

Examples of org.sonatype.nexus.mindexer.client.SearchResponse

        }
      }
    }
    final Integer from = response.getFrom() != -1 ? response.getFrom() : null;
    final Integer count = response.getCount() != -1 ? response.getCount() : null;
    return new SearchResponse(searchRequest, response.getTotalCount(), from, count, response.isTooManyResults(),
        response.isCollapsed(), hits);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.SearchResponse

    String entityText = doSearchForR(queryArgs, repositoryId, searchType, matchers);

    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, entityText, MediaType.APPLICATION_XML);

    return ((SearchResponse) representation.getPayload(new SearchResponse())).getData();
  }
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.