Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rorapi/common/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def build_search_query(params, version):
]
# normalize filter values based on casing conventions used in ROR records
for f in filters:
f[1] = " ".join(f[1].split())
if f[0] == "types":
if version == "v2":
f[1] = f[1].lower()
Expand Down
14 changes: 14 additions & 0 deletions rorapi/tests/tests_unit/tests_queries_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,20 @@ def test_filter_status_filter(self):
query = build_search_query({'filter': f}, self.V2_VERSION)
self.assertEquals(query.to_dict(), expected)

def test_filter_whitespace_normalization(self):
f = 'locations.geonames_details.country_name:South Africa'
expected = {'query': {
'bool': {
'filter': [
{'terms': {'locations.geonames_details.country_name': ('South Africa',)}},
{'terms': {'status': ['active']}}
],
}
}}
expected.update(self.default_query)
query = build_search_query({'filter': f}, self.V2_VERSION)
self.assertEquals(query.to_dict(), expected)

def test_filter_all_status(self):
f = 'key1:val1,k2:value2'
expected = {'query': {
Expand Down