text stringlengths 0 828 |
|---|
{ |
""match"" : { |
""message"" : ""this is a test"" |
} |
} |
Note, message is the name of a field, you can subsitute the name of any field (including _all) instead. |
''' |
instance = cls(match={field: {'query': query}}) |
if operator is not None: |
instance['match'][field]['operator'] = operator |
return instance" |
761,"def bool(cls, must=None, should=None, must_not=None, minimum_number_should_match=None, boost=None): |
''' |
http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html |
A query that matches documents matching boolean combinations of other queris. The bool query maps to Lucene BooleanQuery. It is built using one of more boolean clauses, each clause with a typed occurrence. The occurrence types are: |
'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' clause(s). |
'minimum_number_should_match' - Minimum number of documents that should match |
'boost' - boost value |
> term = ElasticQuery() |
> term.term(user='kimchy') |
> query = ElasticQuery() |
> query.bool(should=term) |
> query.query() |
{ 'bool' : { 'should' : { 'term' : {'user':'kimchy'}}}} |
''' |
instance = cls(bool={}) |
if must is not None: |
instance['bool']['must'] = must |
if should is not None: |
instance['bool']['should'] = should |
if must_not is not None: |
instance['bool']['must_not'] = must_not |
if minimum_number_should_match is not None: |
instance['bool']['minimum_number_should_match'] = minimum_number_should_match |
if boost is not None: |
instance['bool']['boost'] = boost |
return instance" |
762,"def fuzzy(cls, field, value, boost=None, min_similarity=None, prefix_length=None): |
''' |
http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.html |
A fuzzy based query that uses similarity based on Levenshtein (edit distance) algorithm. |
''' |
instance = cls(fuzzy={field: {'value': value}}) |
if boost is not None: |
instance['fuzzy'][field]['boost'] = boost |
if min_similarity is not None: |
instance['fuzzy'][field]['min_similarity'] = min_similarity |
if prefix_length is not None: |
instance['fuzzy'][field]['prefix_length'] = prefix_length |
return instance" |
763,"def fuzzy_like_this(cls, like_text, fields=None, ignore_tf=None, max_query_terms=None, min_similarity=None, prefix_length=None, boost=None, analyzer=None): |
''' |
http://www.elasticsearch.org/guide/reference/query-dsl/flt-query.html |
Fuzzy like this query find documents that are ""like"" provided text by running it against one or more fields. |
> query = ElasticQuery().fuzzy_like_this('text like this one', fields=['name.first', 'name.last'], max_query_terms=12) |
> query |
{'fuzze_like_this': {'boost': 1.0, |
'fields': ['name.first', 'name.last'], |
'ifgnore_tf': False, |
'like_text': 'text like this one', |
'max_query_terms': 12, |
'min_similarity': 0.5, |
'prefix_length': 0}} |
''' |
instance = cls(fuzzy_like_this={'like_text': like_text}) |
if fields is not None: |
instance['fuzzy_like_this']['fields'] = fields |
if ignore_tf is not None: |
instance['fuzzy_like_this']['ignore_tf'] = ignore_tf |
if max_query_terms is not None: |
instance['fuzzy_like_this']['max_query_terms'] = max_query_terms |
if min_similarity is not None: |
instance['fuzzy_like_this']['min_similarity'] = min_similarity |
if prefix_length is not None: |
instance['fuzzy_like_this']['prefix_length'] = prefix_length |
if boost is not None: |
instance['fuzzy_like_this']['boost'] = boost |
if analyzer is not None: |
instance['fuzzy_like_this']['analyzer'] = analyzer |
return instance" |
764,"def has_child(cls, child_type, query): |
''' |
http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query.html |
The has_child query accepts a query and the child type to run against, and results in parent documents that have child docs matching the query. |
> child_query = ElasticQuery().term(tag='something') |
> query = ElasticQuery().has_Child('blog_tag', child_query) |
''' |
instance = cls(has_child={'type': child_type, 'query': query}) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.