def deindex_document(id_, **kwargs): key = keys.document_key(id_) doc = DB.hgetall(key) if not doc: return tokens = [] for indexer in config.DEINDEXERS: indexer(DB, key, doc, tokens, **kwargs)
def deindex_document(id_, **kwargs): key = document_key(id_) doc = DB.hgetall(key) if not doc: return tokens = [] for indexer in config.DEINDEXERS: indexer(DB, key, doc, tokens, **kwargs)
def test_null_value_should_not_be_index(config): doc = { 'id': 'xxxx', 'lat': '49.32545', 'lon': '4.2565', 'name': 'Port-Cergy', 'city': '' } index_document(doc) assert 'city' not in DB.hgetall('d|xxxx')
def test_field_with_only_non_alphanumeric_chars_is_not_indexed(): doc = { 'id': 'xxxx', 'lat': '49.32545', 'lon': '4.2565', 'name': 'Lilas', 'city': '//' } index_document(doc) assert 'city' not in DB.hgetall('d|xxxx')
def test_index_housenumber_uses_housenumber_preprocessors(config): doc = { "id": "xxxx", "type": "street", "name": "rue des Lilas", "city": "Paris", "lat": "49.32545", "lon": "4.2565", "housenumbers": {"1 bis": {"lat": "48.325451", "lon": "2.25651"}}, } index_document(doc) index = DB.hgetall("d|xxxx") assert index[b"h|1b"] == b"1 bis|48.325451|2.25651"
def test_index_housenumber_uses_housenumber_preprocessors(): # By default it glues ordinal to number doc = { 'id': 'xxxx', 'type': 'street', 'name': 'rue des Lilas', 'city': 'Paris', 'lat': '49.32545', 'lon': '4.2565', 'housenumbers': { '1 bis': { 'lat': '48.325451', 'lon': '2.25651' } } } index_document(doc) index = DB.hgetall('d|xxxx') assert index[b'h|1b'] == b'1 bis|48.325451|2.25651'
def test_index_should_join_housenumbers_payload_fields(config): config.HOUSENUMBERS_PAYLOAD_FIELDS = ['key', 'one'] doc = { 'id': 'xxxx', 'type': 'street', 'name': 'rue des Lilas', 'city': 'Paris', 'lat': '49.32545', 'lon': '4.2565', 'housenumbers': { '1 bis': { 'lat': '48.325451', 'lon': '2.25651', 'key': 'myvalue', 'thisone': 'no', 'one': 'two', } } } index_document(doc) index = DB.hgetall('d|xxxx') assert index[b'h|1bis'] == b'1 bis|48.325451|2.25651|myvalue|two'