当前位置: 首页>>代码示例>>Python>>正文


Python helpers.homogeneous函数代码示例

本文整理汇总了Python中tests.helpers.homogeneous函数的典型用法代码示例。如果您正苦于以下问题:Python homogeneous函数的具体用法?Python homogeneous怎么用?Python homogeneous使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了homogeneous函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_queryset_with_multiple_sorting

def test_create_queryset_with_multiple_sorting():
    """
    Create QuerySet with Multiple Sorting
    """
    # When create a query block
    t = QuerySet("foobar")

    # And I add sorting
    s = Sort("_id", order="asc")
    t.order_by(s)

    ss = Sort("_id", order="desc")
    t.order_by(ss)

    # Then I see the appropriate JSON
    results = {
        "sort": [
            {
                "_id": {
                    "order": "asc"
                }
            },
            {
                "_id": {
                    "order": "desc"
                }
            }
        ],
        "query": {
            "match_all": {}
        }
    }

    homogeneous(t._query, results)
开发者ID:jpatel3,项目名称:pyeqs,代码行数:34,代码来源:test_queryset.py

示例2: test_create_queryset_with_multiple_scoring

def test_create_queryset_with_multiple_scoring():
    """
    Create QuerySet with Multiple Scoring
    """
    # When create a query block
    t = QuerySet("foobar")

    # And I add scoring
    s = ScriptScore("foo = 0.0")
    t.score(s)

    # And I add more scoring
    ss = ScriptScore("foo = 1.0")
    t.score(ss)

    # Then I see the appropriate JSON
    results = {
        "query": {
            "function_score": {
                "query": {"match_all": {}},
                "script_score": {
                    "script": "foo = 1.0"
                },
                "boost_mode": "replace"
            }
        }
    }

    homogeneous(t._query, results)
开发者ID:mengjues,项目名称:pyeqs,代码行数:29,代码来源:test_queryset.py

示例3: test_create_queryset_with_scoring

def test_create_queryset_with_scoring():
    """
    Create QuerySet with Scoring, Minimum Score and Track Scores
    """
    # When create a query block
    t = QuerySet("foobar")

    # And I add scoring
    s = ScriptScore("foo = 0.0")
    t.score(s, min_score=0, track_scores=True)

    # Then I see the appropriate JSON
    results = {
        "min_score": 0,
        "track_scores": True,
        "query": {
            "function_score": {
                "functions": [
                    {
                        "script_score": {
                            "script": "foo = 0.0"
                        }
                    }
                ],
                "query": {"match_all": {}},
                "boost_mode": "replace",
                "score_mode": "multiply"
            }
        }
    }

    homogeneous(t._query, results)
开发者ID:jpatel3,项目名称:pyeqs,代码行数:32,代码来源:test_queryset.py

示例4: test_create_queryset_with_filters

def test_create_queryset_with_filters():
    """
    Create QuerySet with Multiple Filters
    """
    # When create a query block
    t = QuerySet("foobar")

    # And I add a filter
    t.filter(Term("foo", "bar"))
    t.filter(Term("foobar", "foobar"))

    # Then I see the appropriate JSON
    results = {
        "query": {
            "filtered": {
                "query": {"match_all": {}},
                "filter": {
                    "and": [
                        {
                            "term": {
                                "foo": "bar"
                            }
                        },
                        {
                            "term": {
                                "foobar": "foobar"
                            }
                        }
                    ]
                }
            }
        }
    }

    homogeneous(t._query, results)
开发者ID:jpatel3,项目名称:pyeqs,代码行数:35,代码来源:test_queryset.py

示例5: test_create_filter

def test_create_filter():
    """
    Create Default Filter
    """
    # When create a filter block
    t = Filter()

    # Then I see the appropriate JSON
    results = {"and": []}

    homogeneous(t, results)
开发者ID:sunchen009,项目名称:pyeqs,代码行数:11,代码来源:test_filter.py

示例6: test_filter_with_and

def test_filter_with_and():
    """
    Create AND Filter
    """
    # When create a filter block
    t = Filter("and")

    # Then I see the appropriate JSON
    results = {"and": []}

    homogeneous(t, results)
开发者ID:sunchen009,项目名称:pyeqs,代码行数:11,代码来源:test_filter.py

示例7: test_filter_with_or

def test_filter_with_or():
    """
    Create OR Filter
    """
    # When create a filter block
    t = Filter("or")

    # Then I see the appropriate JSON
    results = {"or": []}

    homogeneous(t, results)
开发者ID:sunchen009,项目名称:pyeqs,代码行数:11,代码来源:test_filter.py

示例8: test_create_queryset_with_filters_and_scoring

def test_create_queryset_with_filters_and_scoring():
    """
    Create QuerySet with Scoring and Multiple Filters
    """
    # When create a query block
    t = QuerySet("foobar")

    # And I add filtering
    t.filter(Term("foo", "bar"))

    # And I add scoring
    s = ScriptScore("foo = 0.0")
    t.score(s)

    # And I add a second filter
    t.filter(Term("foobar", "foobar"))

    # Then I see the appropriate JSON
    results = {
        "query": {
            "function_score": {
                "query": {
                    "filtered": {
                        "query": {"match_all": {}},
                        "filter": {
                            "and": [
                                {
                                    "term": {
                                        "foo": "bar"
                                    }
                                },
                                {
                                    "term": {
                                        "foobar": "foobar"
                                    }
                                }
                            ]
                        }
                    }
                },
                "functions": [
                    {
                        "script_score": {
                            "script": "foo = 0.0"
                        }
                    }
                ],
                "boost_mode": "replace",
                "score_mode": "multiply"
            }
        }
    }

    homogeneous(t._query, results)
开发者ID:jpatel3,项目名称:pyeqs,代码行数:54,代码来源:test_queryset.py

示例9: test_create_bool

def test_create_bool():
    """
    Create Bool Block
    """
    # When I create a Bool block
    t = Bool()

    # Then I see the appropriate JSON
    results = {
        "bool": {}
    }

    homogeneous(t, results)
开发者ID:Yipit,项目名称:pyeqs,代码行数:13,代码来源:test_bool.py

示例10: test_add_match_all

def test_add_match_all():
    """
    Create Match All Block
    """
    # When add a match all filter
    t = MatchAll()

    # Then I see the appropriate JSON
    results = {
        "match_all": {}
    }

    homogeneous(t, results)
开发者ID:Yipit,项目名称:pyeqs,代码行数:13,代码来源:test_match_all.py

示例11: test_create_queryset

def test_create_queryset():
    """
    Create Default QuerySet
    """
    # When create a queryset
    t = QuerySet("foobar")

    # Then I see the appropriate JSON
    results = {
        "query": {"match_all": {}}
    }

    homogeneous(t._query, results)
开发者ID:jpatel3,项目名称:pyeqs,代码行数:13,代码来源:test_queryset.py

示例12: test_add_score

def test_add_score():
    """
    Create Score Block
    """
    # When add a Score field
    t = ScriptScore("foo")

    # Then I see the appropriate JSON
    results = {
        "script": "foo"
    }

    homogeneous(t, results)
开发者ID:Yipit,项目名称:pyeqs,代码行数:13,代码来源:test_score.py

示例13: test_add_filter

def test_add_filter():
    """
    Create Filter with Block
    """
    # When I create a filter
    t = Filter()

    # And add a block
    t.filter(Term("foo", "bar"))

    # Then I see the appropriate JSON
    results = {"and": [{"term": {"foo": "bar"}}]}

    homogeneous(t, results)
开发者ID:sunchen009,项目名称:pyeqs,代码行数:14,代码来源:test_filter.py

示例14: test_add_score_with_lang

def test_add_score_with_lang():
    """
    Create Score Block with Language
    """
    # When add a Score field
    t = ScriptScore("foo", lang="mvel")

    # Then I see the appropriate JSON
    results = {
        "script": "foo",
        "lang": "mvel"
    }

    homogeneous(t, results)
开发者ID:Yipit,项目名称:pyeqs,代码行数:14,代码来源:test_score.py

示例15: test_add_terms

def test_add_terms():
    """
    Create Terms Block
    """
    # When add a Terms field
    t = Terms("foo", ["bar", "baz"])

    # Then I see the appropriate JSON
    results = {
        "terms": {
            "foo": ["bar", "baz"]
        }
    }

    homogeneous(t, results)
开发者ID:Yipit,项目名称:pyeqs,代码行数:15,代码来源:test_terms.py


注:本文中的tests.helpers.homogeneous函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。