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


Python DB.exists方法代码示例

本文整理汇总了Python中addok.db.DB.exists方法的典型用法代码示例。如果您正苦于以下问题:Python DB.exists方法的具体用法?Python DB.exists怎么用?Python DB.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在addok.db.DB的用法示例。


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

示例1: test_deindex_document_should_deindex_list_values

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_deindex_document_should_deindex_list_values():
    doc = {
        'id': 'xxxx',
        'type': 'street',
        'name': ['Vernou-la-Celle-sur-Seine', 'Vernou'],
        'city': 'Paris',
        'lat': '49.32545',
        'lon': '4.2565'
    }
    index_document(doc)
    deindex_document(doc['id'])
    assert not DB.exists('d|xxxx')
    assert not DB.exists('w|vernou')
    assert not DB.exists('w|celle')
    assert len(DB.keys()) == 0
开发者ID:xlqian,项目名称:addok,代码行数:17,代码来源:test_index_utils.py

示例2: test_should_be_possible_to_define_fields_from_config

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_should_be_possible_to_define_fields_from_config(config):
    config.FIELDS = [
        {'key': 'custom'},
        {'key': 'special'},
    ]
    doc = {
        'id': 'xxxx',
        'lat': '49.32545',
        'lon': '4.2565',
        'custom': 'rue',
        'special': 'Lilas',
        'thisone': 'is not indexed',
    }
    index_document(doc)
    assert DB.exists('d|xxxx')
    assert DB.exists('w|lilas')
    assert DB.exists('w|rue')
    assert not DB.exists('w|indexed')
开发者ID:xlqian,项目名称:addok,代码行数:20,代码来源:test_index_utils.py

示例3: test_doc_with_null_value_should_not_be_index_if_not_allowed

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_doc_with_null_value_should_not_be_index_if_not_allowed(config):
    config.FIELDS = [
        {'key': 'name', 'null': False},
        {'key': 'city'},
    ]
    doc = {
        'id': 'xxxx',
        'lat': '49.32545',
        'lon': '4.2565',
        'name': '',
        'city': 'Cergy'
    }
    index_document(doc)
    assert not DB.exists('d|xxxx')
开发者ID:xlqian,项目名称:addok,代码行数:16,代码来源:test_index_utils.py

示例4: test_create_edge_ngrams

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_create_edge_ngrams(config):
    config.MIN_EDGE_NGRAMS = 2
    doc = {
        'id': 'xxxx',
        'lat': '49.32545',
        'lon': '4.2565',
        'name': '28 Lilas',  # 28 should not appear in ngrams
        'city': 'Paris'
    }
    index_document(doc, update_ngrams=False)
    assert not DB.exists('n|li')
    assert not DB.exists('n|lil')
    assert not DB.exists('n|pa')
    assert not DB.exists('n|par')
    create_edge_ngrams()
    assert DB.exists('n|li')
    assert DB.exists('n|lil')
    assert DB.exists('n|pa')
    assert DB.exists('n|par')
    assert not DB.exists('n|28')
    assert len(DB.keys()) == 12
开发者ID:REIMSMetropole,项目名称:addok,代码行数:23,代码来源:test_index_utils.py

示例5: test_should_be_possible_to_override_boost_with_callable

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_should_be_possible_to_override_boost_with_callable(config):
    config.FIELDS = [
        {'key': 'name', 'boost': lambda doc: 5},
        {'key': 'city'},
    ]
    doc = {
        'id': 'xxxx',
        'lat': '49.32545',
        'lon': '4.2565',
        'name': 'Lilas',
        'city': 'Cergy'
    }
    index_document(doc)
    assert DB.exists('d|xxxx')
    assert DB.zscore('w|lilas', 'd|xxxx') == 5
    assert DB.zscore('w|cergy', 'd|xxxx') == 1
开发者ID:xlqian,项目名称:addok,代码行数:18,代码来源:test_index_utils.py

示例6: test_deindex_document_should_not_affect_other_docs

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_deindex_document_should_not_affect_other_docs():
    DOC2 = {
        'id': 'xxxx2',
        'type': 'street',
        'name': 'rue des Lilas',
        'city': 'Paris',
        'lat': '49.32545',
        'lon': '4.2565',
        'housenumbers': {
            '1': {
                'lat': '48.325451',  # Same geohash as DOC.
                'lon': '2.25651'
            }
        }
    }
    index_document(DOC.copy())
    index_document(DOC2)
    deindex_document(DOC['id'])
    assert not DB.exists('d|xxxx')
    assert DB.exists('w|rue')
    assert DB.exists('w|des')
    assert DB.exists('w|lil')
    assert DB.exists('w|un')  # Housenumber.
    assert b'd|xxxx' not in DB.zrange('w|rue', 0, -1)
    assert b'd|xxxx' not in DB.zrange('w|des', 0, -1)
    assert b'd|xxxx' not in DB.zrange('w|lil', 0, -1)
    assert b'd|xxxx' not in DB.zrange('w|un', 0, -1)
    assert DB.exists('g|u09dgm7')
    assert b'd|xxxx' not in DB.smembers('g|u09dgm7')
    assert b'd|xxxx2' in DB.zrange('w|rue', 0, -1)
    assert b'd|xxxx2' in DB.zrange('w|des', 0, -1)
    assert b'd|xxxx2' in DB.zrange('w|lil', 0, -1)
    assert b'd|xxxx2' in DB.zrange('w|un', 0, -1)
    assert b'd|xxxx2' in DB.smembers('g|u09dgm7')
    assert b'd|xxxx2' in DB.smembers('g|u0g08g7')
    assert DB.exists('f|type|street')
    assert b'd|xxxx2' in DB.smembers('f|type|street')
    assert DB.exists('f|type|housenumber')
    assert b'd|xxxx2' in DB.smembers('f|type|housenumber')
    assert len(DB.keys()) == 14
开发者ID:addok,项目名称:addok-trigrams,代码行数:42,代码来源:test_index.py

示例7: search

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
 def search(self):
     if DB.exists(self.key):
         self.db_key = self.key
开发者ID:digideskio,项目名称:addok,代码行数:5,代码来源:text.py

示例8: test_deindex_document_should_deindex

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_deindex_document_should_deindex():
    index_document(DOC.copy())
    deindex_document(DOC['id'])
    assert not DB.exists('d|xxxx')
    assert not DB.exists('w|de')
    assert not DB.exists('w|lilas')
    assert not DB.exists('w|un')  # Housenumber.
    assert not DB.exists('p|rue')
    assert not DB.exists('p|des')
    assert not DB.exists('p|lilas')
    assert not DB.exists('p|un')
    assert not DB.exists('g|u09dgm7')
    assert not DB.exists('n|lil')
    assert not DB.exists('n|and')
    assert not DB.exists('n|andr')
    assert not DB.exists('n|andre')
    assert not DB.exists('n|andres')
    assert not DB.exists('f|type|street')
    assert len(DB.keys()) == 0
开发者ID:xlqian,项目名称:addok,代码行数:21,代码来源:test_index_utils.py

示例9: test_index_document

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def test_index_document():
    index_document(DOC.copy())
    assert DB.exists('d|xxxx')
    assert DB.type('d|xxxx') == b'hash'
    assert DB.exists('w|rue')
    assert b'd|xxxx' in DB.zrange('w|rue', 0, -1)
    assert DB.exists('w|des')
    assert DB.exists('w|lilas')
    assert DB.exists('w|andresy')
    assert DB.exists('w|un')  # Housenumber.
    assert DB.exists('p|rue')
    assert DB.exists('p|des')
    assert DB.exists('p|lilas')
    assert DB.exists('p|andresy')
    assert b'lilas' in DB.smembers('p|andresy')
    assert b'andresy' in DB.smembers('p|lilas')
    assert DB.exists('p|un')
    assert DB.exists('g|u09dgm7')
    assert b'd|xxxx' in DB.smembers('g|u09dgm7')
    assert DB.exists('n|lil')
    assert DB.exists('n|lila')
    assert DB.exists('n|and')
    assert b'andresy' in DB.smembers('n|and')
    assert DB.exists('n|andr')
    assert b'andresy' in DB.smembers('n|andr')
    assert DB.exists('n|andre')
    assert b'andresy' in DB.smembers('n|andre')
    assert DB.exists('n|andres')
    assert b'andresy' in DB.smembers('n|andres')
    assert b'lilas' in DB.smembers('n|lil')
    assert DB.exists('f|type|street')
    assert b'd|xxxx' in DB.smembers('f|type|street')
    assert DB.exists('f|type|housenumber')
    assert b'd|xxxx' in DB.smembers('f|type|housenumber')
    assert len(DB.keys()) == 20
开发者ID:xlqian,项目名称:addok,代码行数:37,代码来源:test_index_utils.py

示例10: edge_ngram_deindexer

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def edge_ngram_deindexer(db, key, doc, tokens, **kwargs):
    if config.INDEX_EDGE_NGRAMS:
        for token in tokens:
            tkey = dbkeys.token_key(token)
            if not DB.exists(tkey):
                deindex_edge_ngrams(token)
开发者ID:eric-pommereau,项目名称:addok,代码行数:8,代码来源:autocomplete.py

示例11: deindex_token

# 需要导入模块: from addok.db import DB [as 别名]
# 或者: from addok.db.DB import exists [as 别名]
def deindex_token(key, token):
    tkey = token_key(token)
    DB.zrem(tkey, key)
    if not DB.exists(tkey):
        deindex_edge_ngrams(token)
开发者ID:xlqian,项目名称:addok,代码行数:7,代码来源:index.py


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