Exemplo n.º 1
0
def test_geolocation_sort(app):
    """Test geolocation sort."""
    with app.test_request_context("/?pin=10,20&pin=gcpuuz94kkp"):
        v = geolocation_sort('pin', 'km', mode='avg',
                             distance_type='arc')(True)
        assert v == {
            '_geo_distance': {
                'pin.location': ['10,20', 'gcpuuz94kkp'],
                'order': 'asc',
                'unit': 'km',
                'mode': 'avg',
                'distance_type': 'arc',
            }
        }
Exemplo n.º 2
0
def test_geolocation_sort(app):
    """Test geolocation sort."""
    with app.test_request_context("/?pin=10,20&pin=gcpuuz94kkp"):
        v = geolocation_sort(
            'pin.location', 'pin', 'km', mode='avg', distance_type='arc')(True)
        assert v == {
            '_geo_distance': {
                'pin.location': ['10,20', 'gcpuuz94kkp'],
                'order': 'asc',
                'unit': 'km',
                'mode': 'avg',
                'distance_type': 'arc',
            }
        }
Exemplo n.º 3
0
         order=4,
     ),
     journal=dict(
         fields=[
             'journal.year',
             'journal.volume',
             'journal.issue',
             'journal.pages',
         ],
         title='Journal',
         default_order='desc',
         order=6,
     ),
     distance=dict(
         title='Distance',
         fields=[geolocation_sort('location.point', 'center', 'km')],
         default_order='asc',
         display=False,
         order=2,
     ),
     version=dict(
         # TODO: There are a lot of implications when sorting record results
         # by versions and using the `_score`... Maybe there's some
         # elaborate ES syntax/API (eg. `constant_score`) to get a better
         # version-friendly sorted result.
         fields=['conceptrecid', 'relations.version.index'],
         title='Version',
         default_order='desc',
         order=7,
     )
 )
Exemplo n.º 4
0
         order=4,
     ),
     journal=dict(
         fields=[
             'journal.year',
             'journal.volume',
             'journal.issue',
             'journal.pages',
         ],
         title='Journal',
         default_order='desc',
         order=6,
     ),
     distance=dict(
         title='Distance',
         fields=[geolocation_sort('location.point', 'center', 'km')],
         default_order='asc',
         display=False,
         order=2,
     ),
     version=dict(
         # TODO: There are a lot of implications when sorting record results
         # by versions and using the `_score`... Maybe there's some
         # elaborate ES syntax/API (eg. `constant_score`) to get a better
         # version-friendly sorted result.
         fields=['conceptrecid', 'relations.version.index'],
         title='Version',
         default_order='desc',
         order=7,
     )
 )