Returns the base Search object to which the facets are added.

        You can customize the query by overriding this method and returning a
        modified search object.
326963
def search(self):
        
        s = Search(doc_type=self.doc_types, index=self.index, using=self.using)
        return s.response_class(FacetedResponse)
1230006
public static FacetsConfig getFacetsConfig()
    {
        final FacetsConfig ret = new FacetsConfig();
        ret.setHierarchical(Indexer.Dimension.DIMCREATED.name(), true);
        return ret;
    }
625775
def results(self):
        
        if not self.in_search_mode():
            return self.get_queryset()

        # we are doing a search
        objects = self.search()

        # if objects isn't a Search object, just return it, since it's
        # (hopefully) just a list or queryset.
        if not isinstance(objects, Search):
            return objects

        if not self.is_valid_query(objects):
            self.add_error(None, forms.ValidationError("Invalid Query", code="invalid-query"))
            return []

        # convert the search results to something that can be iterated over, and paged
        return Pageable(objects, self.get_queryset())
841940
def get_base(self):
    
    if self._type == 'query':
      return self._observable.get_query_base()
    return self._observable.get_target_base()
362652
def get(self, **kwargs):
        
        default_results_size = current_app.config.get(
            'RECORDS_REST_DEFAULT_RESULTS_SIZE', 10)
        page = request.values.get('page', 1, type=int)
        size = request.values.get('size', default_results_size, type=int)
        if page * size >= self.max_result_window:
            raise MaxResultWindowRESTError()

        # Arguments that must be added in prev/next links
        urlkwargs = dict()
        search_obj = self.search_class()
        search = search_obj.with_preference_param().params(version=True)
        search = search[(page - 1) * size:page * size]

        search, qs_kwargs = self.search_factory(search)
        urlkwargs.update(qs_kwargs)

        # Execute search
        search_result = search.execute()

        # Generate links for prev/next
        urlkwargs.update(
            size=size,
            _external=True,
        )
        endpoint = '.{0}_list'.format(
            current_records_rest.default_endpoint_prefixes[self.pid_type])
        links = dict(self=url_for(endpoint, page=page, **urlkwargs))
        if page > 1:
            links['prev'] = url_for(endpoint, page=page - 1, **urlkwargs)
        if size * page < search_result.hits.total and \
                size * page < self.max_result_window:
            links['next'] = url_for(endpoint, page=page + 1, **urlkwargs)

        return self.make_response(
            pid_fetcher=self.pid_fetcher,
            search_result=search_result.to_dict(),
            links=links,
            item_links_factory=self.item_links_factory,
        )
648805
def default_search_factory(self, search, query_parser=None):
    
    def _default_parser(qstr=None):
        """Default parser that uses the Q() from elasticsearch_dsl."""
        if qstr:
            return Q('query_string', query=qstr)
        return Q()

    from .facets import default_facets_factory
    from .sorter import default_sorter_factory

    query_string = request.values.get('q')
    query_parser = query_parser or _default_parser

    try:
        search = search.query(query_parser(query_string))
    except SyntaxError:
        current_app.logger.debug(
            "Failed parsing query: {0}".format(
                request.values.get('q', '')),
            exc_info=True)
        raise InvalidQueryRESTError()

    search_index = search._index[0]
    search, urlkwargs = default_facets_factory(search, search_index)
    search, sortkwargs = default_sorter_factory(search, search_index)
    for key, value in sortkwargs.items():
        urlkwargs.add(key, value)

    urlkwargs.add('q', query_string)
    return search, urlkwargs
126116
def search(self, pattern):
        
        try:
            return self.advanced_search(pattern)
        except Exception:
            return self.basic_search(pattern)
502777
def search_point(self, point, result):
        
        for k in self.s_center:
            if k.begin <= point < k.end:
                result.add(k)
        if point < self.x_center and self[0]:
            return self[0].search_point(point, result)
        elif point > self.x_center and self[1]:
            return self[1].search_point(point, result)
        return result
923720
def search(self, query, indices=None, doc_types=None, model=None, scan=False, headers=None, **query_params):
        
        if isinstance(query, Search):
            search = query
        elif isinstance(query, (Query, dict)):
            search = Search(query)
        else:
            raise InvalidQuery("search() must be supplied with a Search or Query object, or a dict")

        if scan:
            query_params.setdefault("search_type", "scan")
            query_params.setdefault("scroll", "10m")

        return ResultSet(self, search, indices=indices, doc_types=doc_types,
                         model=model, query_params=query_params, headers=headers)
1217085
public function getModelAdminSearchContext()
    {
        return SearchContext::create(
            get_class($this->getOwner()),
            $this->getOwner()->scaffoldSearchFields(),
            $this->getOwner()->defaultSearchFilters()
        );
    }
110677
def get_queryset(self):
        
        # retrieve all nodes which are published and accessible to current user
        # and use joins to retrieve related fields
        queryset = super(NodeList, self).get_queryset().select_related('status', 'user', 'layer')
        # query string params
        search = self.request.query_params.get('search', None)
        layers = self.request.query_params.get('layers', None)
        if search is not None:
            search_query = (
                Q(name__icontains=search) |
                Q(slug__icontains=search) |
                Q(description__icontains=search) |
                Q(address__icontains=search)
            )
            # add instructions for search to queryset
            queryset = queryset.filter(search_query)
        if layers is not None:
            # look for nodes that are assigned to the specified layers
            queryset = queryset.filter(Q(layer__slug__in=layers.split(',')))
        return queryset
133794
def get_facet_serializer_class(self):
        
        if self.facet_serializer_class is None:
            raise AttributeError(
                "%(cls)s should either include a `facet_serializer_class` attribute, "
                "or override %(cls)s.get_facet_serializer_class() method." %
                {"cls": self.__class__.__name__}
            )
        return self.facet_serializer_class
23168
private SearchNode getSearchNode()
    {
        Object x = _searchNode.get();
        SearchNode g = null;
        if (x != null)
        {
            g = (SearchNode) x;
            g.reset();
        }
        else
        {
            g = new SearchNode();
            x = (Object) g;
            _searchNode.set(x);
        }
        return g;
    }
950639
def result_object(index)
      klass = "Udongo::Search::ResultObjects::#{namespace}::#{index.searchable_type}"
      klass = 'Udongo::Search::ResultObjects::Base' unless result_object_exists?(klass)
      klass.constantize.new(index, search_context: self)
    end
1284940
public JSONObject searchInFacetValues(String facetName, String facetQuery, Query params, RequestOptions requestOptions) throws AlgoliaException {
    params = params == null ? new Query() : params;
    String paramsString = params.setFacetQuery(facetQuery).getQueryString();
    JSONObject body = new JSONObject();
    String encodedFacetName;
    try {
      encodedFacetName = URLEncoder.encode(facetName, "UTF-8");
      body.put("params", paramsString);
    } catch (JSONException e) {
      throw new RuntimeException(e);
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    return client.postRequest("/1/indexes/" + encodedIndexName + "/facets/" + encodedFacetName + "/query", body.toString(), false, true, requestOptions);
  }
196636
def get_query(self):
        

        query = super(ExpandableViewMixin, self).get_query()
        expandable_fields = getattr(self, 'expandable_fields', [])

        if expandable_fields:
            requested_expands = parse_requested_expands(self.schema_class.QUERY_KEY, self.request)

            if requested_expands:
                available_expands = self.expandable_fields.keys()

                for name in requested_expands:
                    if name in available_expands:
                        field = self.expandable_fields[name]

                        innerjoin = field.get('join')
                        outerjoin = field.get('outerjoin')

                        if innerjoin:
                            query = query.join(innerjoin)
                        elif outerjoin:
                            query = query.outerjoin(outerjoin)

                        # Apply optional options
                        options = field.get('options')

                        if options:
                            query = query.options(*options)

        return query
1108390
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
    public void getUpdatedFacetStats() {
        searchable.searchAsync(query, new CompletionHandler() {
            @Override
            public void requestCompleted(JSONObject content, AlgoliaException error) {
                if (error == null) {
                    updateFacetStats(content);
                } else {
                    Log.e("Algolia|Searcher", "Error while getting updated facet stats:" + error.getMessage());
                }
            }
        });
    }