Builder

class es_fluent.builder.QueryBuilder[source]

Bases: object

add_field(field_instance)[source]

Adds a field to the query builder. The default behavior is to return all fields. Explicitly adding a single field will result in only that source field being returned.

Returns:QueryBuilder
add_filter(filter_or_string, *args, **kwargs)[source]

Adds a filter to the query builder’s filters.

Returns:QueryBuilder
add_script_field(field_instance)[source]

Add a script field to the query. The field_instance should be an instance of es_fluent.script_fields.

Returns:QueryBuilder
and_filter(filter_or_string, *args, **kwargs)[source]

Convenience method to delegate to the root_filter to generate an And clause.

Returns:QueryBuilder
disable_source()[source]

Don’t include _source document in results.

Returns:QueryBuilder
enable_source()[source]

Include _source document in results.

Returns:QueryBuilder
find_filter(filter_cls)[source]

Finds an existing filter using a filter class filter_cls. If not found, None is returned.

This method is useful in cases where one wants to modify and extend and existing clause, a common example might be an And filter. The method only looks in the query’s top-level filter and does not recurse.

Param:filter_cls The the Filter class to find.
or_filter(filter_or_string, *args, **kwargs)[source]

Convenience method to delegate to the root_filter to generate an or clause.

Returns:QueryBuilder
remove_sort(field_name)[source]

Clears sorting criteria affecting field_name.

size

Sets current size limit of the ES response, which limits the number of documents returned. By default this is unset and the number of documents returned is up to ES.

Returns:The current size limit.
sort(field, direction='asc')[source]

Adds sort criteria.

sort_reset()[source]

Resets sorting criteria.

to_query()[source]