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


Python elasticsearch_dsl.Index类代码示例

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


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

示例1: create_index_if_does_not_exist

    def create_index_if_does_not_exist(cls):
        index = Index(cls.INDEX_NAME)
        index.doc_type(cls)

        if not index.connection.indices.exists(cls.INDEX_NAME):
            index.create()
            time.sleep(1)  # It takes some time to create the index
开发者ID:Carlosedo,项目名称:mixees,代码行数:7,代码来源:search.py

示例2: test_analyzers_returned_from_to_dict

def test_analyzers_returned_from_to_dict():
    random_analyzer_name = ''.join((choice(string.ascii_letters) for _ in range(100)))
    random_analyzer = analyzer(random_analyzer_name, tokenizer="standard", filter="standard")
    index = Index('i', using='alias')
    index.analyzer(random_analyzer)

    assert index.to_dict()["settings"]["analysis"]["analyzer"][random_analyzer_name] == {"filter": ["standard"], "type": "custom", "tokenizer": "standard"}
开发者ID:gvaldez81,项目名称:elasticsearch-dsl-py,代码行数:7,代码来源:test_index.py

示例3: es_delete_cmd

def es_delete_cmd(index_name):
    """Delete a specified index

    :arg index_name: name of index to delete

    """
    indexes = [name for name, count in get_indexes()]

    if index_name not in indexes:
        log.error('Index "%s" is not a valid index.', index_name)
        if not indexes:
            log.error('There are no valid indexes.')
        else:
            log.error('Valid indexes: %s', ', '.join(indexes))
        return

    ret = raw_input(
        'Are you sure you want to delete "%s"? (yes/no) ' % index_name
    )
    if ret != 'yes':
        return

    log.info('Deleting index "%s"...', index_name)
    index = Index(name=index_name, using='default')
    try:
        index.delete()
    except NotFoundError:
        pass
    log.info('Done!')
开发者ID:digideskio,项目名称:sentiment-analysis,代码行数:29,代码来源:index.py

示例4: test_registered_doc_type_included_in_search

def test_registered_doc_type_included_in_search():
    i = Index('i', using='alias')
    i.doc_type(Post)

    s = i.search()

    assert s._doc_type_map == {'post': Post}
开发者ID:gvaldez81,项目名称:elasticsearch-dsl-py,代码行数:7,代码来源:test_index.py

示例5: __init__

    def __init__(self, config_file='config.cfg'):
        super(Elastic, self).__init__()

        self.percentage=10.0
        self.minimum_occurrences=250

# The ConfigParser documentation points out that there's no way to force defaults config option
# outside the "DEFAULT" section.
        config = ConfigParser()
        config.read(config_file)
        if not config.has_section('elastic'):
            config.add_section('elastic')
        
        for option, value in {'use_ssl': 'True', 'host': '127.0.0.1', 'version': '2', 'index': 'nxapi', 'doc_type': 'events'}.items():
            if not config.has_option('elastic', option):
                config.set('elastic', option, value)

        self.version = config.getint('elastic', 'version')
        self.index = config.get('elastic', 'index')
        use_ssl = config.getboolean('elastic', 'use_ssl')
        host = config.get('elastic', 'host')
        self.doc_type = config.get('elastic', 'doc_type')
        self.client = connections.create_connection(hosts=[host], use_ssl=use_ssl, index=self.index, version=self.version, doc_type=self.doc_type, timeout=30, retry_on_timeout=True )

        Event.init(index=self.index)
        index = Index(self.index, using=self.client)
        index.doc_type(Event)
        self.initialize_search()
开发者ID:nbs-system,项目名称:nxtool,代码行数:28,代码来源:elastic.py

示例6: test_registered_doc_type_included_in_search

def test_registered_doc_type_included_in_search():
    i = Index('i', using='alias')
    i.document(Post)

    s = i.search()

    assert s._doc_type == [Post]
开发者ID:3lnc,项目名称:elasticsearch-dsl-py,代码行数:7,代码来源:test_index.py

示例7: test_index_can_be_saved_even_with_settings

def test_index_can_be_saved_even_with_settings(write_client):
    i = Index('test-blog', using=write_client)
    i.settings(number_of_shards=3, number_of_replicas=0)
    i.save()
    i.settings(number_of_replicas=1)
    i.save()

    assert '1' == i.get_settings()['test-blog']['settings']['index']['number_of_replicas']
开发者ID:elastic,项目名称:elasticsearch-dsl-py,代码行数:8,代码来源:test_index.py

示例8: get_index

def get_index(name, doc_types, *, using, shards=1, replicas=0, interval="1s"):
    index = Index(name, using=using)
    for doc_type in doc_types:
        index.doc_type(doc_type)
    index.settings(
        number_of_shards=shards, number_of_replicas=replicas, refresh_interval=interval
    )
    return index
开发者ID:craig5,项目名称:warehouse,代码行数:8,代码来源:utils.py

示例9: test_aliases_add_to_object

def test_aliases_add_to_object():
    random_alias = ''.join((choice(string.ascii_letters) for _ in range(100)))
    alias_dict = {random_alias: {}}

    index = Index('i', using='alias')
    index.aliases(**alias_dict)

    assert index._aliases == alias_dict
开发者ID:gvaldez81,项目名称:elasticsearch-dsl-py,代码行数:8,代码来源:test_index.py

示例10: test_index_template_can_have_order

def test_index_template_can_have_order():
    i = Index('i-*')
    it = i.as_template('i', order=2)

    assert {
        "index_patterns": ["i-*"],
        "order": 2
    } == it.to_dict()
开发者ID:elastic,项目名称:elasticsearch-dsl-py,代码行数:8,代码来源:test_index.py

示例11: test_aliases_returned_from_to_dict

def test_aliases_returned_from_to_dict():
    random_alias = ''.join((choice(string.ascii_letters) for _ in range(100)))
    alias_dict = {random_alias: {}}

    index = Index('i', using='alias')
    index.aliases(**alias_dict)

    assert index._aliases == index.to_dict()['aliases'] == alias_dict
开发者ID:gvaldez81,项目名称:elasticsearch-dsl-py,代码行数:8,代码来源:test_index.py

示例12: run

 def run(self, *args, **options):
     self.confirm(
         u"Are you really sure you want to delete the index '{0}' ?"
         .format(self.index_name)
     )
     index = Index(self.index_name)
     if not self.dry_run:
         index.delete()
     self.print_success(u"Index {0} deleted.".format(self.index_name))
开发者ID:laurentguilbert,项目名称:django-trampoline,代码行数:9,代码来源:es_delete_index.py

示例13: test_delete

def test_delete(write_client):
    write_client.indices.create(
        index='test-index',
        body={'settings': {'number_of_replicas': 0, 'number_of_shards': 1}}
    )

    i = Index('test-index', using=write_client)
    i.delete()
    assert not write_client.indices.exists(index='test-index')
开发者ID:elastic,项目名称:elasticsearch-dsl-py,代码行数:9,代码来源:test_index.py

示例14: drop_index

def drop_index(silent=True):
    """Remove the ElasticSearch index.
    """
    index = Index(elasticsearch_config['index'])
    try:
        index.delete()
    except Exception as exc:
        if not silent:
            raise exc
开发者ID:mfournier,项目名称:v6_api,代码行数:9,代码来源:initializees.py

示例15: recreate_index

    def recreate_index(self):
        """ Delete and then create a given index and set a default mapping.

        :param index: [string] name of the index. If None a default is used
        """
        submission = Index(self.index)
        submission.delete(ignore=404)

        ESSubmission.init()
开发者ID:HEPData,项目名称:hepdata3,代码行数:9,代码来源:api.py


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