Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchRequest


  public void handleRequest(final RestRequest request, final RestChannel channel) {
    // Get the parameters
    final Map<String, List<String>> params = parseUriParams(request.uri());

    // generate the search request
    SearchRequest searchRequest = getSearchRequest(params, request);
    searchRequest.listenerThreaded(false);

    // execute the search
    client.search(searchRequest, new ActionListener<SearchResponse>() {
      @Override
      public void onResponse(SearchResponse response) {
View Full Code Here


    final String index = request.hasParam("index") ? request.param("index") : "solr";
    final String type = request.hasParam("type") ? request.param("type") : "docs";

    // Build the search Request
    String[] indices = RestActions.splitIndices(index);
    SearchRequest searchRequest = new SearchRequest(indices);
    searchRequest.extraSource(searchSourceBuilder);
    searchRequest.types(RestActions.splitTypes(type));

    return searchRequest;
  }
View Full Code Here

     *
     * Throws a RuntimeException if there are any shard failures to
     * elevate the visibility of the problem.
     */
    public List<String> executeSearch(String source) {
        SearchRequest request = Requests.searchRequest(INDEX_NAME).source(source);

        List<ShardSearchFailure> failures;
        SearchResponse response;

        response = client.search(request).actionGet();
View Full Code Here

     * @param indices The indices to search against. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
     * @return The search request
     * @see org.elasticsearch.client.Client#search(org.elasticsearch.action.search.SearchRequest)
     */
    public static SearchRequest searchRequest(String... indices) {
        return new SearchRequest(indices);
    }
View Full Code Here

public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, SearchResponse> {

    private SearchSourceBuilder sourceBuilder;

    public SearchRequestBuilder(Client client) {
        super(client, new SearchRequest());
    }
View Full Code Here

        controller.registerHandler(GET, "/{index}/{type}/_search", this);
        controller.registerHandler(POST, "/{index}/{type}/_search", this);
    }

    @Override public void handleRequest(final RestRequest request, final RestChannel channel) {
        SearchRequest searchRequest;
        try {
            searchRequest = parseSearchRequest(request);
            searchRequest.listenerThreaded(false);
            SearchOperationThreading operationThreading = SearchOperationThreading.fromString(request.param("operation_threading"), null);
            if (operationThreading != null) {
                if (operationThreading == SearchOperationThreading.NO_THREADS) {
                    // since we don't spawn, don't allow no_threads, but change it to a single thread
                    operationThreading = SearchOperationThreading.SINGLE_THREAD;
                }
                searchRequest.operationThreading(operationThreading);
            }
        } catch (Exception e) {
            if (logger.isDebugEnabled()) {
                logger.debug("failed to parse search request parameters", e);
            }
View Full Code Here

        });
    }

    private SearchRequest parseSearchRequest(RestRequest request) {
        String[] indices = RestActions.splitIndices(request.param("index"));
        SearchRequest searchRequest = new SearchRequest(indices);
        // get the content, and put it in the body
        if (request.hasContent()) {
            searchRequest.source(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), request.contentUnsafe());
        } else {
            String source = request.param("source");
            if (source != null) {
                searchRequest.source(source);
            }
        }
        // add extra source based on the request parameters
        searchRequest.extraSource(parseSearchSource(request));

        searchRequest.searchType(request.param("search_type"));

        String scroll = request.param("scroll");
        if (scroll != null) {
            searchRequest.scroll(new Scroll(parseTimeValue(scroll, null)));
        }

        searchRequest.timeout(request.paramAsTime("timeout", null));
        searchRequest.types(RestActions.splitTypes(request.param("type")));
        searchRequest.queryHint(request.param("query_hint"));
        searchRequest.routing(request.param("routing"));
        searchRequest.preference(request.param("preference"));

        return searchRequest;
    }
View Full Code Here

                if (searchTypes == null) {
                    searchTypes = new String[]{request.type()};
                }
                int size = request.searchSize() != 0 ? request.searchSize() : 10;
                int from = request.searchFrom() != 0 ? request.searchFrom() : 0;
                SearchRequest searchRequest = searchRequest(searchIndices)
                        .types(searchTypes)
                        .searchType(request.searchType())
                        .scroll(request.searchScroll())
                        .extraSource(searchSource()
                                .query(boolBuilder)
                                .from(from)
                                .size(size)
                        )
                        .listenerThreaded(request.listenerThreaded());

                if (request.searchSource() != null) {
                    searchRequest.source(request.searchSource(), request.searchSourceOffset(), request.searchSourceLength(), request.searchSourceUnsafe());
                }
                searchAction.execute(searchRequest, new ActionListener<SearchResponse>() {
                    @Override public void onResponse(SearchResponse response) {
                        listener.onResponse(response);
                    }
View Full Code Here

        request.searchRequest(searchRequest);
        return this;
    }

    public PutWarmerRequestBuilder<JsonInput, JsonOutput> source(String index, String type, JsonInput source) {
        request.searchRequest(new SearchRequest(index).types(type).source(jsonToString(source)));
        return this;
    }
View Full Code Here

        request.searchRequest(new SearchRequest(index).types(type).source(jsonToString(source)));
        return this;
    }

    public PutWarmerRequestBuilder<JsonInput, JsonOutput> source(String index, JsonInput source) {
        request.searchRequest(new SearchRequest(index).source(jsonToString(source)));
        return this;
    }
View Full Code Here

TOP

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

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.