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

Python base.ElasticSearchBase类代码示例

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

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



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

示例1: test_build_query_from_params

    def test_build_query_from_params(self):
        # Test with all default parameters
        config = self.get_dummy_context()
        params = {}
        params = scommon.get_parameters(params)
        query = ElasticSearchBase.build_query_from_params(params, config)
        self.assertTrue(query)
        self.assertTrue("query" in query)
        self.assertTrue("size" in query)
        self.assertTrue("from" in query)

        # Searching for a term in a specific field and with a specific product
        params = {
            "terms": "hang",
            "fields": "dump",
            "search_mode": "contains",
            "products": "fennec"
        }
        params = scommon.get_parameters(params)
        query = ElasticSearchBase.build_query_from_params(params, config)
        self.assertTrue(query)
        self.assertTrue("query" in query)
        self.assertTrue("filtered" in query["query"])

        filtered = query["query"]["filtered"]
        self.assertTrue("query" in filtered)
        self.assertTrue("wildcard" in filtered["query"])
        self.assertTrue("dump" in filtered["query"]["wildcard"])

        dump_term = filtered["query"]["wildcard"]["dump"]
        self.assertEqual(dump_term, "*hang*")
        self.assertTrue("filter" in filtered)
        self.assertTrue("and" in filtered["filter"])
开发者ID:Meghashyamt,项目名称:socorro,代码行数:33,代码来源:test_base.py


示例2: test_build_terms_query

    def test_build_terms_query(self):
        # Empty query
        fields = ""
        terms = None
        query = ElasticSearchBase.build_terms_query(fields, terms)
        self.assertFalse(query)

        #......................................................................
        # Single term, single field query
        fields = "signature"
        terms = "hang"
        query = ElasticSearchBase.build_terms_query(fields, terms)
        self.assertTrue("term" in query)
        self.assertTrue(fields in query["term"])
        self.assertEqual(query["term"][fields], terms)

        #......................................................................
        # Multiple terms, single field query
        fields = "signature"
        terms = ["hang", "flash", "test"]
        query = ElasticSearchBase.build_terms_query(fields, terms)
        self.assertTrue("terms" in query)
        self.assertTrue(fields in query["terms"])
        self.assertEqual(query["terms"][fields], terms)

        #......................................................................
        # Multiple terms, multiple fields query
        fields = ["signature", "dump"]
        terms = ["hang", "flash"]
        query = ElasticSearchBase.build_terms_query(fields, terms)
        self.assertTrue("terms" in query)
        for field in fields:
            self.assertTrue(field in query["terms"])
            self.assertEqual(query["terms"][field], terms)
开发者ID:Meghashyamt,项目名称:socorro,代码行数:34,代码来源:test_base.py


示例3: __init__

    def __init__(self, *args, **kwargs):
        config = kwargs.get('config')

        # We have multiple inheritance here, explicitly calling superclasses's
        # init is mandatory.
        # See http://freshfoo.com/blog/object__init__takes_no_parameters
        SearchBase.__init__(self, config=config)
        ElasticSearchBase.__init__(self, config=config)
开发者ID:JisJis,项目名称:socorro,代码行数:8,代码来源:supersearch.py


示例4: test_generate_list_of_indexes

    def test_generate_list_of_indexes(self):
        config = self._get_default_config()
        es = ElasticSearchBase(config=config)

        from_date = datetime.datetime(2000, 1, 1, 0, 0)
        to_date = datetime.datetime(2000, 1, 16, 0, 0)

        indexes = es.generate_list_of_indexes(from_date, to_date)
        indexes_exp = ["socorro200000", "socorro200001", "socorro200002"]

        self.assertEqual(indexes, indexes_exp)
开发者ID:rfw,项目名称:socorro,代码行数:11,代码来源:test_base.py


示例5: test_format_versions

def test_format_versions():
    """
    Test ElasticSearchBase.format_versions()
    """
    # Empty versions
    versions = None
    version_res = ElasticSearchBase.format_versions(versions)
    assert not version_res, (
                "The versions string is %s, null expected." % version_res)

    # Only one product, no version
    versions = ["firefox"]
    version_res = ElasticSearchBase.format_versions(versions)
    assert isinstance(version_res, list), (
                "Results should be a list, %s received" % type(version_res))
    assert version_res == [{ "product": "firefox", "version": None}], (
                "Wrong formatting of versions for one product, no version: "
                "%s" % version_res)

    # One product, one version
    versions = ["firefox:5.0.1b"]
    version_res = ElasticSearchBase.format_versions(versions)
    assert isinstance(version_res, list), (
                "Results should be a list, %s received" % type(version_res))
    assert "product" in version_res[0], "Result should have a product"
    assert "version" in version_res[0], "Result should have a version"
    assert version_res[0]["product"] == "firefox", (
                "Result's product is wrong, expected 'firefox', received %s" %
                version_res[0]["product"])
    assert version_res[0]["version"] == "5.0.1b", (
                "Result's version is wrong, expected '5.0.1b', received %s" %
                version_res[0]["version"])

    # Multiple products, multiple versions
    versions = ["firefox:5.0.1b", "fennec:1"]
    version_res = ElasticSearchBase.format_versions(versions)
    assert type(version_res) is list, (
                "Results should be a list, %s received" % type(version_res))
    for v in version_res:
        assert "product" in v, "Result should have a product"
        assert "version" in v, "Result should have a version"

    assert version_res[0]["product"] == "firefox", (
                "Result's product is wrong, expected 'firefox', received %s" %
                version_res[0]["product"])
    assert version_res[0]["version"] == "5.0.1b", (
                "Result's version is wrong, expected '5.0.1b', received %s" %
                version_res[0]["version"])
    assert version_res[1]["product"] == "fennec", (
                "Result's product is wrong, expected 'fennec', received %s" %
                version_res[1]["product"])
    assert version_res[1]["version"] == "1", (
                "Result's version is wrong, expected '1', received %s" %
                version_res[1]["version"])
开发者ID:mattloci,项目名称:socorro,代码行数:54,代码来源:test_base.py


示例6: test_build_terms_query

def test_build_terms_query():
    """
    Test ElasticSearchBase.build_terms_query()
    """
    # Empty query
    fields = ""
    terms = None
    query = ElasticSearchBase.build_terms_query(fields, terms)
    assert not query

    # Single term, single field query
    fields = "signature"
    terms = "hang"
    query = ElasticSearchBase.build_terms_query(fields, terms)
    assert "term" in query, (
                "Single term, single field query does not have a term field: "
                "%s" % query)
    assert fields in query["term"], (
                "Term query does not have the asked %s field: %s" %
                (fields, query))
    assert query["term"][fields] == terms, (
                "Term query's value is %s, should be %s in query %s" %
                (query["term"][fields], terms, query))

    # Multiple terms, single field query
    fields = "signature"
    terms = ["hang", "flash", "test"]
    query = ElasticSearchBase.build_terms_query(fields, terms)
    assert "terms" in query, (
                "Single term, single field query does not have a term field: "
                "%s" % query)
    assert fields in query["terms"], (
                "Term query does not have the asked %s field: %s" %
                (fields, query))
    assert query["terms"][fields] == terms, (
                "Term query's value is %s, should be %s in query %s" %
                (query["term"][fields], terms, query))

    # Multiple terms, multiple fields query
    fields = ["signature", "dump"]
    terms = ["hang", "flash"]
    query = ElasticSearchBase.build_terms_query(fields, terms)
    assert "terms" in query, (
                "Single term, single field query does not have a term field: "
                "%s" % query)
    for field in fields:
        assert field in query["terms"], (
                    "Term query does not have the asked %s field: %s" %
                    (field, query))
        assert query["terms"][field] == terms, (
                    "Term query's value is %s, should be %s in query %s" %
                    (query["term"][field], terms, query))
开发者ID:mattloci,项目名称:socorro,代码行数:52,代码来源:test_base.py


示例7: test_build_wildcard_query

def test_build_wildcard_query():
    """
    Test ElasticSearchBase.build_wildcard_query()
    """
    # Empty query
    fields = ""
    terms = None
    query = ElasticSearchBase.build_wildcard_query(fields, terms)
    assert not query, "Query is %s, null or empty expected." % query

    # Single term, single field query
    fields = "signature"
    terms = "hang"
    query = ElasticSearchBase.build_wildcard_query(fields, terms)
    assert "wildcard" in query, (
                "Single term, single field query does not have "
                "a wildcard field: %s" % query)
    assert "signature.full" in query["wildcard"], (
                "Term query does not have the asked %s field: %s" %
                (fields, query))
    assert query["wildcard"]["signature.full"] == terms, (
                "Term query's value is %s, should be %s in query %s" %
                (query["term"][fields], terms, query))

    # Multiple terms, single field query
    fields = "dump"
    terms = ["hang", "flash", "test"]
    query = ElasticSearchBase.build_wildcard_query(fields, terms)
    assert "wildcard" in query, (
                "Single term, single field query does not have "
                "a wildcard field: %s" % query)
    assert fields in query["wildcard"], (
                "Term query does not have the asked %s field: %s" %
                (fields, query))
    assert query["wildcard"][fields] == terms, (
                "Term query's value is %s, should be %s in query %s" %
                (query["term"][fields], terms, query))

    # Multiple terms, multiple fields query
    fields = ["reason", "dump"]
    terms = ["hang", "flash"]
    query = ElasticSearchBase.build_wildcard_query(fields, terms)
    assert "wildcard" in query, (
                "Single term, single field query does not have "
                "a wildcard field: %s" % query)
    for field in fields:
        assert field in query["wildcard"], (
                    "Term query does not have the asked %s field: %s" %
                    (field, query))
        assert query["wildcard"][field] == terms, (
                    "Term query's value is %s, should be %s in query %s" %
                    (query["term"][field], terms, query))
开发者ID:mattloci,项目名称:socorro,代码行数:52,代码来源:test_base.py


示例8: test_build_query_from_params

def test_build_query_from_params():
    """
    Test ElasticSearchBase.build_query_from_params()
    """
    # Test with all default parameters
    args = {
        "config": get_dummy_context()
    }
    search = ElasticSearchBase(**args)
    params = {}
    params = scommon.get_parameters(params)
    query = ElasticSearchBase.build_query_from_params(params)
    assert query, "build_query_from_params returned a bad value: %s" % query
    assert "query" in query, (
                "query is malformed, 'query' key missing: %s" % query)
    assert "size" in query, (
                "query is malformed, 'size' key missing: %s" % query)
    assert "from" in query, (
                "query is malformed, 'from' key missing: %s" % query)

    # Searching for a term in a specific field and with a specific product
    params = {
        "terms": "hang",
        "fields": "dump",
        "search_mode": "contains",
        "products": "fennec"
    }
    params = scommon.get_parameters(params)
    query = ElasticSearchBase.build_query_from_params(params)
    assert query, "build_query_from_params returned a bad value: %s" % query
    assert "query" in query, (
                "query is malformed, 'query' key missing: %s" % query)
    assert "filtered" in query["query"], (
                "query is malformed, 'filtered' key missing: %s" % query)

    filtered = query["query"]["filtered"]
    assert "query" in filtered, (
                "query is malformed,  'query' key missing: %s" % query)
    assert "wildcard" in filtered["query"], (
                "query is malformed, 'wildcard' key missing: %s" % query)
    assert "dump" in filtered["query"]["wildcard"], (
                "query is malformed, 'dump' key missing: %s" % query)

    dump_term = filtered["query"]["wildcard"]["dump"]
    assert "*hang*" == dump_term, (
                "query is malformed, value for wildcard is wrong: %s" % query)
    assert "filter" in filtered, (
                "query is malformed, 'filter' key missing: %s" % query)
    assert "and" in filtered["filter"], (
                "query is malformed, 'and' key missing: %s" % query)
开发者ID:mattloci,项目名称:socorro,代码行数:50,代码来源:test_base.py


示例9: __init__

    def __init__(self, *args, **kwargs):
        config = kwargs.get('config')
        ElasticSearchBase.__init__(self, config=config)

        self.all_fields = self.get_fields()

        self.database_name_to_field_name_map = dict(
            (x['in_database_name'], x['name'])
            for x in self.all_fields.values()
        )

        # We have multiple inheritance here, explicitly calling superclasses's
        # init is mandatory.
        # See http://freshfoo.com/blog/object__init__takes_no_parameters
        SearchBase.__init__(self, config=config, fields=self.all_fields)
开发者ID:FrostburnStudios,项目名称:socorro,代码行数:15,代码来源:supersearch.py


示例10: test_generate_list_of_indexes

    def test_generate_list_of_indexes(self):
        config = self._get_default_config()
        es = ElasticSearchBase(config=config)

        from_date = datetime.datetime(2000, 1, 1, 0, 0)
        to_date = datetime.datetime(2000, 1, 16, 0, 0)

        indexes = es.generate_list_of_indexes(from_date, to_date)
        indexes_exp = [
            'socorro200000',
            'socorro200001',
            'socorro200002',
        ]

        eq_(indexes, indexes_exp)
开发者ID:Earth4,项目名称:socorro,代码行数:15,代码来源:test_base.py


示例11: test_query

    def test_query(self, mock_http):
        config = self._get_default_config()
        es = ElasticSearchBase(config=config)

        def post_fn(uri, query):
            if "socorro200002" in uri:
                return {"error": {"code": 404, "data": "IndexMissingException[[socorro200002]]"}}
            return ""

        mock_http.HttpClient.return_value.post = post_fn

        from_date = datetime.datetime(2000, 1, 1, 0, 0)
        to_date = datetime.datetime(2000, 1, 16, 0, 0)
        json_query = "{}"

        res = es.query(from_date, to_date, json_query)

        self.assertEqual(res, ("", "text/json"))
开发者ID:rfw,项目名称:socorro,代码行数:18,代码来源:test_base.py


示例12: test_query

    def test_query(self, mock_http):
        config = self._get_default_config()
        es = ElasticSearchBase(config=config)

        def post_fn(uri, query):
            if 'socorro200002' in uri:
                return {
                    'error': {
                        'code': 404,
                        'data': 'IndexMissingException[[socorro200002]]'
                    }
                }
            return ''
        mock_http.HttpClient.return_value.post = post_fn

        from_date = datetime.datetime(2000, 1, 1, 0, 0)
        to_date = datetime.datetime(2000, 1, 16, 0, 0)
        json_query = '{}'

        res = es.query(from_date, to_date, json_query)

        self.assertEqual(res, ('', "text/json"))
开发者ID:erikrose,项目名称:socorro,代码行数:22,代码来源:test_base.py


示例13: test_build_wildcard_query

    def test_build_wildcard_query(self):
        # Empty query
        fields = ""
        terms = None
        query = ElasticSearchBase.build_wildcard_query(fields, terms)
        ok_(not query)

        #......................................................................
        # Single term, single field query
        fields = "signature"
        terms = "hang"
        query = ElasticSearchBase.build_wildcard_query(fields, terms)
        ok_("wildcard" in query)
        ok_("processed_crash.signature.full" in query["wildcard"])
        eq_(
            query["wildcard"]["processed_crash.signature.full"],
            terms
        )

        #......................................................................
        # Multiple terms, single field query
        fields = "dump"
        prefixed_field = "processed_crash.dump"
        terms = ["hang", "flash", "test"]
        query = ElasticSearchBase.build_wildcard_query(fields, terms)
        ok_("wildcard" in query)
        ok_(prefixed_field in query["wildcard"])
        eq_(query["wildcard"][prefixed_field], terms)

        #......................................................................
        # Multiple terms, multiple fields query
        fields = ["reason", "dump"]
        terms = ["hang", "flash"]
        query = ElasticSearchBase.build_wildcard_query(fields, terms)
        ok_("wildcard" in query)
        for field in fields:
            prefixed_field = "processed_crash.%s" % field
            ok_(prefixed_field in query["wildcard"])
            eq_(query["wildcard"][prefixed_field], terms)
开发者ID:Earth4,项目名称:socorro,代码行数:39,代码来源:test_base.py


示例14: test_format_versions

    def test_format_versions(self):
        # Empty versions
        versions = None
        version_res = ElasticSearchBase.format_versions(versions)
        ok_(not version_res)

        #......................................................................
        # Only one product, no version
        versions = ["firefox"]
        version_res = ElasticSearchBase.format_versions(versions)
        version_res_exp = [{"product": "firefox", "version": None}]
        ok_(isinstance(version_res, list))
        eq_(version_res, version_res_exp)

        #......................................................................
        # One product, one version
        versions = ["firefox:5.0.1b"]
        version_res = ElasticSearchBase.format_versions(versions)
        ok_(isinstance(version_res, list))
        ok_("product" in version_res[0])
        ok_("version" in version_res[0])
        eq_(version_res[0]["product"], "firefox")
        eq_(version_res[0]["version"], "5.0.1b")

        #......................................................................
        # Multiple products, multiple versions
        versions = ["firefox:5.0.1b", "fennec:1"]
        version_res = ElasticSearchBase.format_versions(versions)
        ok_(isinstance(version_res, list))
        for v in version_res:
            ok_("product" in v)
            ok_("version" in v)

        eq_(version_res[0]["product"], "firefox")
        eq_(version_res[0]["version"], "5.0.1b")
        eq_(version_res[1]["product"], "fennec")
        eq_(version_res[1]["version"], "1")
开发者ID:Earth4,项目名称:socorro,代码行数:37,代码来源:test_base.py


示例15: test_format_versions

    def test_format_versions(self):
        # Empty versions
        versions = None
        version_res = ElasticSearchBase.format_versions(versions)
        self.assertFalse(version_res)

        #......................................................................
        # Only one product, no version
        versions = ["firefox"]
        version_res = ElasticSearchBase.format_versions(versions)
        version_res_exp = [{"product": "firefox", "version": None}]
        self.assertTrue(isinstance(version_res, list))
        self.assertEqual(version_res, version_res_exp)

        #......................................................................
        # One product, one version
        versions = ["firefox:5.0.1b"]
        version_res = ElasticSearchBase.format_versions(versions)
        self.assertTrue(isinstance(version_res, list))
        self.assertTrue("product" in version_res[0])
        self.assertTrue("version" in version_res[0])
        self.assertEqual(version_res[0]["product"], "firefox")
        self.assertEqual(version_res[0]["version"], "5.0.1b")

        #......................................................................
        # Multiple products, multiple versions
        versions = ["firefox:5.0.1b", "fennec:1"]
        version_res = ElasticSearchBase.format_versions(versions)
        self.assertTrue(isinstance(version_res, list))
        for v in version_res:
            self.assertTrue("product" in v)
            self.assertTrue("version" in v)

        self.assertEqual(version_res[0]["product"], "firefox")
        self.assertEqual(version_res[0]["version"], "5.0.1b")
        self.assertEqual(version_res[1]["product"], "fennec")
        self.assertEqual(version_res[1]["version"], "1")
开发者ID:Meghashyamt,项目名称:socorro,代码行数:37,代码来源:test_base.py


示例16: test_prepare_terms

def test_prepare_terms():
    """
    Test Search.prepare_terms()
    """
    # Empty terms
    terms = []
    search_mode = None
    newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
    assert not newterms, "Terms are %s, null or empty expected." % newterms

    # Contains mode, single term
    terms = ["test"]
    search_mode = "contains"
    newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
    assert newterms == "*test*", (
                "Terms are not well prepared, missing stars around: %s" %
                newterms)

    # Contains mode, multiple terms
    terms = ["test", "hang"]
    search_mode = "contains"
    newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
    assert newterms == "*test hang*", (
                "Terms are not well prepared, missing stars around: %s" %
                newterms)

    # Starts with mode, multiple terms
    terms = ["test", "hang"]
    search_mode = "starts_with"
    newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
    assert newterms == "test hang*", (
                "Terms are not well prepared, missing stars after: %s" %
                newterms)

    # Is exactly mode, multiple terms
    terms = ["test", "hang"]
    search_mode = "is_exactly"
    newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
    assert newterms == " ".join(terms), (
                "Terms should be concatenated when using a is_exactly mode.")

    # Random unexisting mode, multiple terms
    terms = ["test", "hang"]
    search_mode = "random_unexisting_mode"
    newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
    assert newterms == terms, (
                "Terms should not be changed when using a mode other than "
                "is_exactly, starts_with or contains.")
开发者ID:mattloci,项目名称:socorro,代码行数:48,代码来源:test_base.py


示例17: test_prepare_terms

    def test_prepare_terms(self):
        """
        Test Search.prepare_terms()
        """
        # Empty terms
        terms = []
        search_mode = None
        newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
        self.assertFalse(newterms)

        # Contains mode, single term
        terms = ["test"]
        search_mode = "contains"
        newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
        self.assertEqual(newterms, "*test*")

        # Contains mode, multiple terms
        terms = ["test", "hang"]
        search_mode = "contains"
        newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
        self.assertEqual(newterms, "*test hang*")

        # Starts with mode, multiple terms
        terms = ["test", "hang"]
        search_mode = "starts_with"
        newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
        self.assertEqual(newterms, "test hang*")

        # Is exactly mode, multiple terms
        terms = ["test", "hang"]
        search_mode = "is_exactly"
        newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
        self.assertEqual(newterms, " ".join(terms))

        # Random unexisting mode, multiple terms
        terms = ["test", "hang"]
        search_mode = "random_unexisting_mode"
        newterms = ElasticSearchBase.prepare_terms(terms, search_mode)
        self.assertEqual(newterms, terms)
开发者ID:Meghashyamt,项目名称:socorro,代码行数:39,代码来源:test_base.py


示例18: test_build_query_from_params

    def test_build_query_from_params(self):
        # Test with all default parameters
        config = self.get_dummy_context()
        params = {}
        params = scommon.get_parameters(params)
        query = ElasticSearchBase.build_query_from_params(params, config)
        self.assertTrue(query)
        self.assertTrue("query" in query)
        self.assertTrue("size" in query)
        self.assertTrue("from" in query)

        # Searching for a term in a specific field and with a specific product
        params = {
            "terms": "hang",
            "fields": "dump",
            "search_mode": "contains",
            "products": "fennec"
        }
        params = scommon.get_parameters(params)
        query = ElasticSearchBase.build_query_from_params(params, config)
        self.assertTrue(query)
        self.assertTrue("query" in query)
        self.assertTrue("filtered" in query["query"])

        filtered = query["query"]["filtered"]
        self.assertTrue("query" in filtered)
        self.assertTrue("wildcard" in filtered["query"])
        self.assertTrue("dump" in filtered["query"]["wildcard"])

        dump_term = filtered["query"]["wildcard"]["dump"]
        self.assertEqual(dump_term, "*hang*")
        self.assertTrue("filter" in filtered)
        self.assertTrue("and" in filtered["filter"])

        # Test versions
        params = {
            "products": "WaterWolf",
            "versions": "WaterWolf:1.0a1"
        }
        params = scommon.get_parameters(params)
        params['versions_info'] = {
            'WaterWolf:1.0a1': {
                "version_string": "1.0a1",
                "product_name": "WaterWolf",
                "major_version": "1.0a1",
                "release_channel": "nightly-water",
                "build_id": None
            }
        }
        query = ElasticSearchBase.build_query_from_params(params, config)
        filtered = query["query"]["filtered"]

        self.assertTrue("and" in filtered["filter"])
        and_filter_str = json.dumps(filtered["filter"]['and'])
        self.assertTrue('WaterWolf' in and_filter_str)
        self.assertTrue('1.0a1' in and_filter_str)
        self.assertTrue('nightly-water' in and_filter_str)

        # Test versions with an empty release channel in versions_info
        params = {
            "products": "WaterWolf",
            "versions": "WaterWolf:2.0"
        }
        params = scommon.get_parameters(params)
        params['versions_info'] = {
            'WaterWolf:2.0': {
                "version_string": "2.0",
                "product_name": "WaterWolf",
                "major_version": "2.0",
                "release_channel": None,
                "build_id": None
            }
        }
        query = ElasticSearchBase.build_query_from_params(params, config)
        filtered = query["query"]["filtered"]

        self.assertTrue("and" in filtered["filter"])
        and_filter_str = json.dumps(filtered["filter"]['and'])
        self.assertTrue('WaterWolf' in and_filter_str)
        self.assertTrue('2.0' in and_filter_str)
开发者ID:erikrose,项目名称:socorro,代码行数:80,代码来源:test_base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python crashstorage.ElasticSearchCrashStorage类代码示例发布时间:2022-05-27
下一篇:
Python database.singleValueSql函数代码示例发布时间: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