def test_allow_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) assert DB.zscore('w|vernou', 'd|xxxx') == 4 assert DB.zscore('w|celle', 'd|xxxx') == 4 / 5
def test_allow_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) assert DB.zscore('w|vernou', 'd|xxxx') == 4 assert DB.zscore('w|celle', 'd|xxxx') == 4 / 5
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
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 ds._DB.exists('d|xxxx') assert DB.zscore('w|lilas', 'd|xxxx') == 5 assert DB.zscore('w|cergy', 'd|xxxx') == 1
def test_should_be_possible_to_override_boost_from_config(config): config.FIELDS = [ { 'key': 'name', 'boost': 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|lila', 'd|xxxx') == 5 assert DB.zscore('w|serji', 'd|xxxx') == 1