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 b'd|xxxx' not in DB.zrange('w|ru', 0, -1) assert b'd|xxxx' not in DB.zrange('w|de', 0, -1) assert b'd|xxxx' not in DB.zrange('w|lila', 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 DB.exists('w|de') assert DB.exists('w|lila') assert DB.exists('w|un') # Housenumber. assert DB.exists('p|ru') assert b'd|xxxx2' in DB.zrange('w|ru', 0, -1) assert b'd|xxxx2' in DB.zrange('w|de', 0, -1) assert b'd|xxxx2' in DB.zrange('w|lila', 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('p|de') assert DB.exists('p|lila') assert DB.exists('p|un') assert not DB.exists('n|and') assert not DB.exists('n|andr') assert not DB.exists('n|andre') assert not DB.exists('n|andrez') assert DB.exists('n|par') assert DB.exists('n|lil') assert b'lila' in DB.smembers('n|lil') 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()) == 17
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|sel') assert len(DB.keys()) == 0
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|lila') assert not DB.exists('w|un') # Housenumber. assert not DB.exists('p|ru') assert not DB.exists('p|de') assert not DB.exists('p|lila') 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|andrez') assert not DB.exists('f|type|street') assert len(DB.keys()) == 0
def process(doc): if doc.get('_action') in ['delete', 'update']: deindex_document(doc['id']) if doc.get('_action') in ['index', 'update', None]: index_document(doc, update_ngrams=False)
def test_deindex_document_should_not_fail_if_id_do_not_exist(): deindex_document('xxxxx')