def __init__( self, request, separate_replies=False, separate_wildcard_uri_keys=True, _replies_limit=200, ): self.es = request.es self.separate_replies = separate_replies self._replies_limit = _replies_limit # Order matters! The KeyValueMatcher must be run last, # after all other modifiers have popped off the params. self._modifiers = [ query.Sorter(), query.Limiter(), query.DeletedFilter(), query.AuthFilter(request), query.GroupFilter(), query.GroupAuthFilter(request), query.UserFilter(), query.HiddenFilter(request), query.AnyMatcher(), query.TagsMatcher(), query.UriCombinedWildcardFilter( request, separate_keys=separate_wildcard_uri_keys ), query.KeyValueMatcher(), ] self._aggregations = []
def __init__(self, request, separate_replies=False, stats=None, _replies_limit=200): self.es = request.es self.separate_replies = separate_replies self.stats = stats self._replies_limit = _replies_limit # Order matters! The KeyValueMatcher must be run last, # after all other modifiers have popped off the params. self._modifiers = [ query.Sorter(), query.Limiter(), query.DeletedFilter(), query.AuthFilter(request), query.GroupFilter(), query.GroupAuthFilter(request), query.UserFilter(), query.NipsaFilter(request), query.AnyMatcher(), query.TagsMatcher(), query.KeyValueMatcher() ] self._aggregations = []
def test_any_query(self): anymatcher = query.AnyMatcher() result = anymatcher({"any": "foo"}) assert result == { "simple_query_string": { "fields": ["quote", "tags", "text", "uri.parts"], "query": "foo", } }
def _default_querybuilder(request, es): builder = query.Builder(es_version=es.version) builder.append_filter(query.DeletedFilter()) builder.append_filter(query.AuthFilter(request)) builder.append_filter(query.UriFilter(request)) builder.append_filter(query.GroupFilter()) builder.append_filter(query.GroupAuthFilter(request)) builder.append_filter(query.UserFilter()) builder.append_filter(query.NipsaFilter(request)) builder.append_matcher(query.AnyMatcher()) builder.append_matcher(query.TagsMatcher()) return builder
def default_querybuilder(request): builder = query.Builder() builder.append_filter(query.DeletedFilter()) builder.append_filter(query.AuthFilter(request)) builder.append_filter(query.UriFilter(request)) builder.append_filter(query.GroupFilter()) builder.append_filter(query.UserFilter()) builder.append_matcher(query.AnyMatcher()) builder.append_matcher(query.TagsMatcher()) for factory in request.registry.get(FILTERS_KEY, []): builder.append_filter(factory(request)) return builder
def test_multiple_params(self): """Multiple keywords at once are handled correctly.""" anymatcher = query.AnyMatcher() params = multidict.MultiDict() params.add("any", "howdy") params.add("any", "there") result = anymatcher(params) assert result == { "simple_query_string": { "fields": ["quote", "tags", "text", "uri.parts"], "query": "howdy there", } }
def search(self, search): search.append_modifier(query.AnyMatcher()) return search