detect exact match for ES property queries (#793)
* detect exact match for ES property queries * detect exact match for ES property queries * update tests
This commit is contained in:
@@ -236,13 +236,19 @@ class ElasticsearchProvider(BaseProvider):
|
||||
if properties:
|
||||
LOGGER.debug('processing properties')
|
||||
for prop in properties:
|
||||
prop_name = self.mask_prop(prop[0])
|
||||
pf = {
|
||||
'match': {
|
||||
self.mask_prop(prop[0]): prop[1]
|
||||
prop_name: {
|
||||
'query': prop[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
query['query']['bool']['filter'].append(pf)
|
||||
|
||||
if '|' not in prop[1]:
|
||||
pf['match'][prop_name]['minimum_should_match'] = '100%'
|
||||
|
||||
if sortby:
|
||||
LOGGER.debug('processing sortby')
|
||||
query['sort'] = []
|
||||
|
||||
@@ -161,9 +161,9 @@ def test_query(config):
|
||||
assert results['features'][0]['properties']['nameascii'] == 'Vatican City'
|
||||
|
||||
results = p.query(properties=[('nameascii', 'Vatican City')])
|
||||
assert len(results['features']) == 4
|
||||
assert results['numberMatched'] == 4
|
||||
assert results['numberReturned'] == 4
|
||||
assert len(results['features']) == 1
|
||||
assert results['numberMatched'] == 1
|
||||
assert results['numberReturned'] == 1
|
||||
|
||||
results = p.query(limit=1)
|
||||
assert len(results['features']) == 1
|
||||
|
||||
Reference in New Issue
Block a user