pyes.query

class pyes.query.BoolQuery(must=None, must_not=None, should=None, boost=None, minimum_number_should_match=1, disable_coord=None, **kwargs)

A boolean combination of other queries.

BoolQuery maps to Lucene BooleanQuery. It is built using one or more boolean clauses, each clause with a typed occurrence. The occurrence types are:

Occur Description
must The clause (query) must appear in matching documents.
should The clause (query) should appear in the matching document. A boolean query with no must clauses, one or more should clauses must match a document. The minimum number of should clauses to match can be set using minimum_number_should_match parameter.
must_not The clause (query) must not appear in the matching documents. Note that it is not possible to search on documents that only consists of a must_not clauses.

The bool query also supports disable_coord parameter (defaults to false).

add_must(queries)

Add a query to the “must” clause of the query.

The Query object will be returned, so calls to this can be chained.

add_must_not(queries)

Add a query to the “must_not” clause of the query.

The Query object will be returned, so calls to this can be chained.

add_should(queries)

Add a query to the “should” clause of the query.

The Query object will be returned, so calls to this can be chained.

is_empty()
serialize()
class pyes.query.ConstantScoreQuery(filter=None, boost=1.0, **kwargs)

Returns a constant score for all documents matching a filter.

Multiple filters may be supplied by passing a sequence or iterator as the filter parameter. If multiple filters are supplied, documents must match all of them to be matched by this query.

add(filter)

Add a filter, or a list of filters, to the query.

If a sequence of filters is supplied, they are all added, and will be combined with an ANDFilter.

is_empty()

Returns True if the query is empty.

serialize()
class pyes.query.CustomScoreQuery(query=None, script=None, params=None, lang=None, **kwargs)
add_param(name, value)

Add a parameter

serialize()
class pyes.query.DisMaxQuery(query=None, tie_breaker=0.0, boost=1.0, queries=None, **kwargs)
add(query)
serialize()
class pyes.query.FieldParameter(field, query, default_operator='OR', analyzer=None, allow_leading_wildcard=True, lowercase_expanded_terms=True, enable_position_increments=True, fuzzy_prefix_length=0, fuzzy_min_sim=0.5, phrase_slop=0, boost=1.0)
serialize()
class pyes.query.FieldQuery(fieldparameters=None, default_operator='OR', analyzer=None, allow_leading_wildcard=True, lowercase_expanded_terms=True, enable_position_increments=True, fuzzy_prefix_length=0, fuzzy_min_sim=0.5, phrase_slop=0, boost=1.0, use_dis_max=True, tie_breaker=0, **kwargs)
add(field, query, **kwargs)
serialize()
class pyes.query.FilterQuery(filters=None, **kwargs)
add(filterquery)
serialize()
class pyes.query.FilteredQuery(query, filter, **kwargs)
serialize()
class pyes.query.FuzzyLikeThisFieldQuery(field, like_text, ignore_tf=False, max_query_terms=25, boost=1.0, **kwargs)
serialize()
class pyes.query.FuzzyLikeThisQuery(fields, like_text, ignore_tf=False, max_query_terms=25, min_similarity=0.5, prefix_length=0, boost=1.0, **kwargs)
serialize()
class pyes.query.FuzzyQuery(field, value, boost=None, min_similarity=0.5, prefix_length=0, **kwargs)

A fuzzy based query that uses similarity based on Levenshtein (edit distance) algorithm.

Note
Warning: this query is not very scalable with its default prefix length of 0 - in this case, every term will be enumerated and cause an edit score calculation. Here is a simple example:
serialize()
class pyes.query.HasChildQuery(type, query, _scope=None, **kwargs)
serialize()
class pyes.query.IdsQuery(type, values, **kwargs)
serialize()
class pyes.query.MatchAllQuery(boost=None, **kwargs)
serialize()
class pyes.query.MoreLikeThisFieldQuery(field, like_text, percent_terms_to_match=0.29999999999999999, min_term_freq=2, max_query_terms=25, stop_words=None, min_doc_freq=5, max_doc_freq=None, min_word_len=0, max_word_len=0, boost_terms=1, boost=1.0, **kwargs)
serialize()
class pyes.query.MoreLikeThisQuery(fields, like_text, percent_terms_to_match=0.29999999999999999, min_term_freq=2, max_query_terms=25, stop_words=None, min_doc_freq=5, max_doc_freq=None, min_word_len=0, max_word_len=0, boost_terms=1, boost=1.0, **kwargs)
serialize()
class pyes.query.PercolatorQuery(doc, query=None, **kwargs)

A percolator query is used to determine which registered PercolatorDoc’s match the document supplied.

search(**kwargs)

Disable this as it is not allowed in percolator queries.

serialize()

Serialize the query to a structure using the query DSL.

to_search_json()

Disable this as it is not allowed in percolator queries.

class pyes.query.PrefixQuery(field=None, prefix=None, boost=None, **kwargs)
add(field, prefix, boost=None)
serialize()
class pyes.query.Query(*args, **kwargs)

Base class for all queries.

search(**kwargs)

Return this query wrapped in a Search object.

Any keyword arguments supplied to this call will be passed to the Search object.

serialize()

Serialize the query to a structure using the query DSL.

to_query_json()

Convert the query to JSON using the query DSL.

The output of this is suitable for using as the request body for count, delete_by_query and reindex.

to_search_json()

Convert the query to JSON suitable for searching with.

The output of this is suitable for using as the request body for search.

class pyes.query.RangeQuery(qrange=None, **kwargs)
add(qrange)
serialize()
class pyes.query.RegexTermQuery(*args, **kwargs)
class pyes.query.Search(query=None, fields=None, start=None, size=None, highlight=None, sort=None, explain=False, facet=None, version=None, track_scores=None, script_fields=None, index_boost={})

A search to be performed.

This contains a query, and has additional parameters which are used to control how the search works, what it should return, etc.

add_highlight(field, fragment_size=None, number_of_fragments=None)

Add a highlight field.

The Search object will be returned, so calls to this can be chained.

add_index_boost(index, boost)

Add a boost on an index.

The Search object will be returned, so calls to this can be chained.

get_facet_factory()

Returns the facet factory

q
serialize()

Serialize the search to a structure as passed for a search body.

to_search_json()

Convert the search to JSON.

The output of this is suitable for using as the request body for search.

class pyes.query.SpanFirstQuery(field=None, value=None, end=3, **kwargs)
serialize()
class pyes.query.SpanNearQuery(clauses=None, slop=None, in_order=None, collect_payloads=None, **kwargs)

Matches spans which are near one another. One can specify _slop_, the maximum number of intervening unmatched positions, as well as whether matches are required to be in-order.

The clauses element is a list of one or more other span type queries and the slop controls the maximum number of intervening unmatched positions permitted.

serialize()
class pyes.query.SpanNotQuery(include, exclude, **kwargs)

Removes matches which overlap with another span query.

The include and exclude clauses can be any span type query. The include clause is the span query whose matches are filtered, and the exclude clause is the span query whose matches must not overlap those returned.

serialize()
class pyes.query.SpanOrQuery(clauses=None, **kwargs)

Matches the union of its span clauses.

The clauses element is a list of one or more other span type queries.

serialize()
class pyes.query.SpanTermQuery(**kwargs)
class pyes.query.StringQuery(query, default_field=None, search_fields=None, default_operator='OR', analyzer=None, allow_leading_wildcard=True, lowercase_expanded_terms=True, enable_position_increments=True, fuzzy_prefix_length=0, fuzzy_min_sim=0.5, phrase_slop=0, boost=1.0, analyze_wildcard=False, use_dis_max=True, tie_breaker=0, clean_text=False, **kwargs)
serialize()
class pyes.query.TermQuery(field=None, value=None, boost=None, **kwargs)

Match documents that have fields that contain a term (not analyzed).

A boost may be supplied.

add(field, value, boost=None)
serialize()
class pyes.query.TermsQuery(*args, **kwargs)
add(field, value, minimum_match=1)
class pyes.query.TextQuery(field, text, type='boolean', slop=0, fuzziness=None, prefix_length=0, max_expansions=2147483647, operator='or', analyzer=None, **kwargs)

A new family of text queries that accept text, analyzes it, and constructs a query out of it.

add_query(field, text, type='boolean', slop=0, fuzziness=None, prefix_length=0, max_expansions=2147483647, operator='or', analyzer=None)
serialize()
class pyes.query.TopChildrenQuery(type, score='max', factor=5, incremental_factor=2, **kwargs)
serialize()
class pyes.query.WildcardQuery(*args, **kwargs)
pyes.query.is_a_spanquery(obj)

Returns if the object is a span query

Previous topic

pyes.mappings

Next topic

pyes.rivers

This Page