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:
Tom Kralidis
2021-10-11 20:21:44 -04:00
committed by GitHub
parent 7b34101b7a
commit 4b85a6a8eb
2 changed files with 10 additions and 4 deletions
+7 -1
View File
@@ -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'] = []
+3 -3
View File
@@ -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