# Path: elasticsearch_dsl/function.py
# def SF(name_or_sf, **params):
#     def to_dict(self):
#     def to_dict(self):
# class ScoreFunction(DslBase):
# class ScriptScore(ScoreFunction):
# class BoostFactor(ScoreFunction):
# class RandomScore(ScoreFunction):
# class FieldValueFactor(ScoreFunction):
# class Linear(ScoreFunction):
# class Gauss(ScoreFunction):
# class Exp(ScoreFunction):
# 
# Path: elasticsearch_dsl/query.py
# def Q(name_or_query="match_all", **params):
#     def __add__(self, other):
#     def __invert__(self):
#     def __or__(self, other):
#     def __and__(self, other):
#     def __add__(self, other):
#     def __or__(self, other):
#     def __invert__(self):
#     def __add__(self, other):
#     def __or__(self, other):
#     def __invert__(self):
#     def __add__(self, other):
#     def __or__(self, other):
#     def _min_should_match(self):
#     def __invert__(self):
#     def __and__(self, other):
#     def __init__(self, **kwargs):
# class Query(DslBase):
# class MatchAll(Query):
# class MatchNone(Query):
# class Bool(Query):
# class FunctionScore(Query):
# class Boosting(Query):
# class ConstantScore(Query):
# class DisMax(Query):
# class Filtered(Query):
# class Indices(Query):
# class Percolate(Query):
# class Nested(Query):
# class HasChild(Query):
# class HasParent(Query):
# class TopChildren(Query):
# class SpanFirst(Query):
# class SpanMulti(Query):
# class SpanNear(Query):
# class SpanNot(Query):
# class SpanOr(Query):
# class FieldMaskingSpan(Query):
# class SpanContaining(Query):
# class SpanWithin(Query):
# class CombinedFields(Query):
# class Common(Query):
# class Fuzzy(Query):
# class FuzzyLikeThis(Query):
# class FuzzyLikeThisField(Query):
# class RankFeature(Query):
# class DistanceFeature(Query):
# class GeoBoundingBox(Query):
# class GeoDistance(Query):
# class GeoDistanceRange(Query):
# class GeoPolygon(Query):
# class GeoShape(Query):
# class GeohashCell(Query):
# class Ids(Query):
# class Intervals(Query):
# class Limit(Query):
# class Match(Query):
# class MatchPhrase(Query):
# class MatchPhrasePrefix(Query):
# class MatchBoolPrefix(Query):
# class Exists(Query):
# class MoreLikeThis(Query):
# class MoreLikeThisField(Query):
# class MultiMatch(Query):
# class Prefix(Query):
# class QueryString(Query):
# class Range(Query):
# class Regexp(Query):
# class Shape(Query):
# class SimpleQueryString(Query):
# class SpanTerm(Query):
# class Template(Query):
# class Term(Query):
# class Terms(Query):
# class TermsSet(Query):
# class Wildcard(Query):
# class Script(Query):
# class ScriptScore(Query):
# class Type(Query):
# class ParentId(Query):
# class Wrapper(Query):
# EMPTY_QUERY = MatchAll()


from pytest import raises
from elasticsearch_dsl import function, query

    d = {
        "function_score": {
            "query": {"match": {"title": "python"}},
            "functions": [
                {"random_score": {}},
                {
                    "filter": {"term": {"tags": "python"}},
                    "field_value_factor": {"field": "comment_count"},
                },
            ],
        }
    }
    assert d == q.to_dict()


def test_function_score_with_single_function():
    d = {
        "function_score": {
            "filter": {"term": {"tags": "python"}},
            "script_score": {"script": "doc['comment_count'] * _score"},
        }
    }

    q = query.Q(d)
    assert isinstance(q, query.FunctionScore)
    assert isinstance(q.filter, query.Term)
    assert len(q.functions) == 1

    sf = q.functions[0]

# Path: elasticsearch_dsl/function.py
# def SF(name_or_sf, **params):
#     def to_dict(self):
#     def to_dict(self):
# class ScoreFunction(DslBase):
# class ScriptScore(ScoreFunction):
# class BoostFactor(ScoreFunction):
# class RandomScore(ScoreFunction):
# class FieldValueFactor(ScoreFunction):
# class Linear(ScoreFunction):
# class Gauss(ScoreFunction):
# class Exp(ScoreFunction):
# 
# Path: elasticsearch_dsl/query.py
# def Q(name_or_query="match_all", **params):
#     def __add__(self, other):
#     def __invert__(self):
#     def __or__(self, other):
#     def __and__(self, other):
#     def __add__(self, other):
#     def __or__(self, other):
#     def __invert__(self):
#     def __add__(self, other):
#     def __or__(self, other):
#     def __invert__(self):
#     def __add__(self, other):
#     def __or__(self, other):
#     def _min_should_match(self):
#     def __invert__(self):
#     def __and__(self, other):
#     def __init__(self, **kwargs):
# class Query(DslBase):
# class MatchAll(Query):
# class MatchNone(Query):
# class Bool(Query):
# class FunctionScore(Query):
# class Boosting(Query):
# class ConstantScore(Query):
# class DisMax(Query):
# class Filtered(Query):
# class Indices(Query):
# class Percolate(Query):
# class Nested(Query):
# class HasChild(Query):
# class HasParent(Query):
# class TopChildren(Query):
# class SpanFirst(Query):
# class SpanMulti(Query):
# class SpanNear(Query):
# class SpanNot(Query):
# class SpanOr(Query):
# class FieldMaskingSpan(Query):
# class SpanContaining(Query):
# class SpanWithin(Query):
# class CombinedFields(Query):
# class Common(Query):
# class Fuzzy(Query):
# class FuzzyLikeThis(Query):
# class FuzzyLikeThisField(Query):
# class RankFeature(Query):
# class DistanceFeature(Query):
# class GeoBoundingBox(Query):
# class GeoDistance(Query):
# class GeoDistanceRange(Query):
# class GeoPolygon(Query):
# class GeoShape(Query):
# class GeohashCell(Query):
# class Ids(Query):
# class Intervals(Query):
# class Limit(Query):
# class Match(Query):
# class MatchPhrase(Query):
# class MatchPhrasePrefix(Query):
# class MatchBoolPrefix(Query):
# class Exists(Query):
# class MoreLikeThis(Query):
# class MoreLikeThisField(Query):
# class MultiMatch(Query):
# class Prefix(Query):
# class QueryString(Query):
# class Range(Query):
# class Regexp(Query):
# class Shape(Query):
# class SimpleQueryString(Query):
# class SpanTerm(Query):
# class Template(Query):
# class Term(Query):
# class Terms(Query):
# class TermsSet(Query):
# class Wildcard(Query):
# class Script(Query):
# class ScriptScore(Query):
# class Type(Query):
# class ParentId(Query):
# class Wrapper(Query):
# EMPTY_QUERY = MatchAll()


# Path: tests/test_query.py
from pytest import raises
from elasticsearch_dsl import function, query


    d = {
        "function_score": {
            "query": {"match": {"title": "python"}},
            "functions": [
                {"random_score": {}},
                {
                    "filter": {"term": {"tags": "python"}},
                    "field_value_factor": {"field": "comment_count"},
                },
            ],
        }
    }
    assert d == q.to_dict()


def test_function_score_with_single_function():
    d = {
        "function_score": {
            "filter": {"term": {"tags": "python"}},
            "script_score": {"script": "doc['comment_count'] * _score"},
        }
    }

    q = query.Q(d)
    assert isinstance(q, query.FunctionScore)
    assert isinstance(q.filter, query.Term)
    assert len(q.functions) == 1

    sf = q.functions[0]

    assert isinstance(sf, function.ScriptScore)