• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python helpers.homogeneous函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_add_sort_desc

def test_add_sort_desc():
    """
    Create Sort Block Descending
    """
    # When add a Sort block
    t = Sort("foo", order="dsc")

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

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


示例17: test_add_type

def test_add_type():
    """
    Create Type Block
    """
    # When add a Type Block
    t = Type("foo")

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

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


示例18: test_add_sort

def test_add_sort():
    """
    Create Sort Block
    """
    # When add a Sort block
    t = Sort("foo")

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

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


示例19: test_missing

def test_missing():
    """
    Create Missing Block
    """
    # When add a Missing Block
    t = Missing("foo")

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

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


示例20: test_add_agg

def test_add_agg():
    """
    Create aggregations block
    """
    # When add an agg block
    t = Aggregations("agg_name", "field_name", "metric")

    # Then I see correct json
    results = {
        "agg_name": {
            "metric": {"field": "field_name"}
        }
    }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.raises函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.get_tempstoreclient函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap