pyes.filters

class pyes.filters.ANDFilter(filters, **kwargs)

A filter that matches combinations of other filters using the AND operator

Example:

t1 = TermFilter(‘name’, ‘john’) t2 = TermFilter(‘name’, ‘smith’) f = ANDFilter([t1, t2]) q = FilteredQuery(MatchAllQuery(), f) results = conn.search(q)

class pyes.filters.BoolFilter(must=None, must_not=None, should=None, minimum_number_should_match=None, **kwargs)

A filter that matches documents matching boolean combinations of other queries. Similar in concept to Boolean query, except that the clauses are other filters. Can be placed within queries that accept a filter.

add_must(queries)
add_must_not(queries)
add_should(queries)
is_empty()
class pyes.filters.ExistsFilter(field, **kwargs)
class pyes.filters.Filter(**kwargs)
serialize()
class pyes.filters.FilterList(filters, **kwargs)
class pyes.filters.GeoBoundingBoxFilter(field, location_tl, location_br, **kwargs)

http://github.com/elasticsearch/elasticsearch/issues/290

class pyes.filters.GeoDistanceFilter(field, location, distance, distance_type='arc', distance_unit=None, optimize_bbox='memory', **kwargs)

http://github.com/elasticsearch/elasticsearch/issues/279

class pyes.filters.GeoIndexedShapeFilter(field=None, id=None, type=None, index=None, path=None, **kwargs)

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html#_pre_indexed_shape

class pyes.filters.GeoPolygonFilter(field, points, **kwargs)

http://github.com/elasticsearch/elasticsearch/issues/294

class pyes.filters.GeoShapeFilter(field=None, coordinates=None, type=None, **kwargs)

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html

class pyes.filters.HasChildFilter(type, query, _scope=None, **kwargs)

The has_child filter accepts a query and the child type to run against, and results in parent documents that have child docs matching the query

class pyes.filters.HasFilter(type, query, _scope=None, **kwargs)
class pyes.filters.HasParentFilter(type, query, _scope=None, **kwargs)

The has_parent filter accepts a query and the parent type to run against, and results in child documents that have parent docs matching the query

class pyes.filters.IdsFilter(values, type=None, **kwargs)
class pyes.filters.LimitFilter(value=100, **kwargs)
class pyes.filters.MatchAllFilter(**kwargs)

A filter that matches on all documents

class pyes.filters.MissingFilter(field, existence=None, null_value=None, **kwargs)
class pyes.filters.NestedFilter(path, filter, join=None, **kwargs)

A nested filter, works in a similar fashion to the nested query, except used as a filter. It follows exactly the same structure, but also allows to cache the results (set _cache to true), and have it named (set the _name value).

class pyes.filters.NotFilter(filter, **kwargs)
pyes.filters.NumericRangeFilter

alias of RangeFilter

class pyes.filters.ORFilter(filters, **kwargs)

A filter that matches combinations of other filters using the OR operator

Example:

t1 = TermFilter(‘name’, ‘john’) t2 = TermFilter(‘name’, ‘smith’) f = ORFilter([t1, t2]) q = FilteredQuery(MatchAllQuery(), f) results = conn.search(q)

class pyes.filters.PrefixFilter(field=None, prefix=None, **kwargs)
add(field, prefix)
class pyes.filters.QueryFilter(query, **kwargs)
class pyes.filters.RangeFilter(qrange=None, execution=None, **kwargs)
add(qrange)
negate()

Negate some ranges: useful to resolve a NotFilter(RangeFilter(**))

class pyes.filters.RawFilter(filter_text_or_dict, **kwargs)

Uses exactly the filter provided as an ES filter.

serialize()
class pyes.filters.RegexTermFilter(field=None, value=None, ignorecase=False, **kwargs)
add(field, value, ignorecase=False)
class pyes.filters.ScriptFilter(script, params=None, lang=None, **kwargs)
add(field, value)
class pyes.filters.TermFilter(field=None, value=None, **kwargs)
add(field, value)
class pyes.filters.TermsFilter(field=None, values=None, execution=None, **kwargs)

If you want to use the Terms lookup feature, you can do it like that:

from pyes.utils import TermsLookup

Example:

tl = TermsLookup(index=’index’, type=’type’, id=’id’, path=’path’) f = TermsFilter(‘key’, tl)

q = FilteredQuery(MatchAllQuery(), f) results = conn.search(q)

add(field, values)
class pyes.filters.TypeFilter(type, **kwargs)