Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchRequestBuilder.addFields()


        // TODO: Check if we can get away without loading the _source field.
        // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html#search-request-fields
        // "For backwards compatibility, if the fields parameter specifies fields which are not stored , it will
        // load the _source and extract it from it. This functionality has been replaced by the source filtering
        // parameter." -- So we should look at the source filtering parameter once we switched to ES 1.x.
        srb.addFields(fields.toArray(new String[fields.size()]));
        srb.addField("_source"); // always request the _source field because otherwise we can't access non-stored values

        final SearchRequest request = srb.setSearchType(SearchType.SCAN)
                .setScroll(new TimeValue(1, TimeUnit.MINUTES))
                .setSize(500).request(); // TODO magic numbers
View Full Code Here


            // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html#search-request-fields
            // "For backwards compatibility, if the fields parameter specifies fields which are not stored , it will
            // load the _source and extract it from it. This functionality has been replaced by the source filtering
            // parameter."
            // TODO: Look at the source filtering parameter once we switched to ES 1.x.
            request.addFields(config.fields().toArray(new String[config.fields().size()]));
        }

        return request;
    }
View Full Code Here

    if (searchQuery.getFilter() != null) {
      requestBuilder.setPostFilter(searchQuery.getFilter());
    }

    if (isNotEmpty(searchQuery.getFields())) {
      requestBuilder.addFields(toArray(searchQuery.getFields()));
    }

    if (noFields) {
      requestBuilder.setNoFields();
    }
View Full Code Here

      searchRequestBuilder.setSize(query.getPageable().getPageSize());
    }
    searchRequestBuilder.setFrom(startRecord);

    if (!query.getFields().isEmpty()) {
      searchRequestBuilder.addFields(toArray(query.getFields()));
    }

    if (query.getSort() != null) {
      for (Sort.Order order : query.getSort()) {
        searchRequestBuilder.addSort(order.getProperty(), order.getDirection() == Sort.Direction.DESC ? SortOrder.DESC
View Full Code Here

  public SearchResponse performSearch(Client client) {
    SearchRequestBuilder request = client.prepareSearch(SearchQueueListener.MESSAGES_INDEX);

    request.setTypes(SearchQueueListener.MESSAGES_TYPE);

    request.addFields(
            "title",
            "topic_title",
            "author",
            "postdate",
            "topic_id",
View Full Code Here

    requestBuilder.setQuery(queryBuilder);
    logger.debug("Searching for {}", requestBuilder.toString());

    // Make sure all fields are being returned
    if (query.getFields().length > 0) {
      requestBuilder.addFields(query.getFields());
      requestBuilder.addField(IndexSchema.RESOURCE_ID);
      requestBuilder.addField(IndexSchema.PATH);
      requestBuilder.addField(IndexSchema.VERSION);
    } else {
      requestBuilder.addField("*");
 
View Full Code Here

        }
        searchRequestBuilder.setFrom(startRecord);


        if(!query.getFields().isEmpty()){
            searchRequestBuilder.addFields(toArray(query.getFields()));
        }

        if(query.getSort() != null){
            for(Sort.Order order : query.getSort()){
                searchRequestBuilder.addSort(order.getProperty(), order.getDirection() == Sort.Direction.DESC? SortOrder.DESC : SortOrder.ASC);
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.