Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
995c2c5
Update __process_multi_match (partial impl)
VadimKovalenkoSNF May 30, 2025
3415102
Add slop parameter to the multi match query
VadimKovalenkoSNF Jun 2, 2025
14778fa
Add unit tests
VadimKovalenkoSNF Jun 5, 2025
b510ada
Fix flake8 issues
VadimKovalenkoSNF Jun 5, 2025
d1df32d
Update release notes
VadimKovalenkoSNF Jun 5, 2025
4d73130
Add extra paragraph
VadimKovalenkoSNF Jun 5, 2025
04e3d88
Fix integration test for the OpenSearch
VadimKovalenkoSNF Jun 6, 2025
314d2a9
Merge branch 'main' into OSDEV-2033-fix-long-strings-query-param
VadimKovalenkoSNF Jun 6, 2025
f39dbb5
Merge branch 'main' into OSDEV-2033-fix-long-strings-query-param
VadimKovalenkoSNF Jun 9, 2025
7cbb00f
Merge branch 'main' into OSDEV-2033-fix-long-strings-query-param
VadimKovalenkoSNF Jun 9, 2025
da63e1d
Add cleanup in opensearch integration tests
VadimKovalenkoSNF Jun 9, 2025
613421f
Update test_production_locations
VadimKovalenkoSNF Jun 9, 2025
f83605b
Merge branch 'main' into OSDEV-2033-fix-long-strings-query-param
VadimKovalenkoSNF Jun 10, 2025
cc23cca
Test fix for integration test
VadimKovalenkoSNF Jun 10, 2025
df97362
Add refresh method
VadimKovalenkoSNF Jun 10, 2025
fb3fef1
Minor test improvements
VadimKovalenkoSNF Jun 10, 2025
4c9d7ae
Add cleanup between tests
VadimKovalenkoSNF Jun 10, 2025
66f9254
Test fix for src/tests/v1/test_production_locations.py
VadimKovalenkoSNF Jun 10, 2025
849d451
Simplified test cases
VadimKovalenkoSNF Jun 10, 2025
fb18f1d
Fix release notes
VadimKovalenkoSNF Jun 10, 2025
0434036
Revert production locations tests
VadimKovalenkoSNF Jun 10, 2025
482b976
Minor fix
VadimKovalenkoSNF Jun 10, 2025
f344d2b
Add paragraph at the end of test file
VadimKovalenkoSNF Jun 12, 2025
9d96f0a
Merge branch 'main' into OSDEV-2033-fix-long-strings-query-param
VadimKovalenkoSNF Jun 12, 2025
a60a485
Merge branch 'main' into OSDEV-2033-fix-long-strings-query-param
VadimKovalenkoSNF Jun 16, 2025
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
26 changes: 24 additions & 2 deletions doc/release/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,28 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## Introduction
* Product name: Open Supply Hub
* Release date: Jun 28, 2025
* Release date: June 28, 2025

### Database changes
* *Describe high-level database changes.*

Comment thread
VadimKovalenkoSNF marked this conversation as resolved.
#### Migrations:
* *Describe migrations here.*

Comment thread
VadimKovalenkoSNF marked this conversation as resolved.
#### Schema changes
* *Describe schema changes here.*

### Code/API changes
* *Describe code/API changes here.*

### Architecture/Environment changes
* *Describe architecture/environment changes here.*

Comment thread
VadimKovalenkoSNF marked this conversation as resolved.
### Bugfix
* [OSDEV-2033](https://opensupplyhub.atlassian.net/browse/OSDEV-2033) - Added support for the `slop` parameter in `multi_match` queries when using strings longer than 50 symbols or 12 tokens in GET `v1/production-locations?query=` endpoint.

### What's new
* *Describe what's new here. The changes that can impact user experience should be listed in this section.*
Comment thread
VadimKovalenkoSNF marked this conversation as resolved.

### Database changes
* *Describe high-level database changes.*
Expand Down Expand Up @@ -66,11 +87,12 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
* `migrate`
* `reindex_database`


## Release 2.6.0

## Introduction
* Product name: Open Supply Hub
* Release date: Jun 14, 2025
* Release date: June 14, 2025

### Architecture/Environment changes
* [OSDEV-1925](https://opensupplyhub.atlassian.net/browse/OSDEV-1925) - This PR disables the automatic execution of the `Deploy to AWS` pipeline on `releases/*` branch creation via the `[Release] Init` pipeline, while retaining automatic execution on push events to the same branch.
Expand Down
23 changes: 23 additions & 0 deletions src/django/api/tests/test_production_locations_query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,29 @@ def test_add_multi_match(self):
expected, self.builder.query_body['query']['bool']['must']
)

self.builder.reset()
self.builder.add_multi_match(
'Mount Isa Mines Limited Copper Refineries Pty Ltd CRL', slop=3
)
expected_with_slop = {
'multi_match': {
'query': (
'Mount Isa Mines Limited Copper Refineries Pty Ltd '
'CRL'
),
'fields': ['name^2', 'address', 'description', 'local_name'],
'type': 'phrase',
'slop': 3
}
}
self.assertIn(
expected_with_slop,
self.builder.query_body['query']['bool']['must']
)
must_clauses = self.builder.query_body['query']['bool']['must']
multi_match_query = must_clauses[0]['multi_match']
self.assertNotIn('fuzziness', multi_match_query)

def test_add_aggregations_with_precision(self):
aggregation = 'geohex_grid'
geohex_grid_precision = 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def __process_multi_match(self, query_params):
multi_match_query = query_params.get(V1_PARAMETERS_LIST.QUERY)

if multi_match_query and hasattr(self.__builder, 'add_multi_match'):
self.__builder.add_multi_match(multi_match_query)
tokens = multi_match_query.split()
if len(tokens) > 12 or len(multi_match_query) > 50:
self.__builder.add_multi_match(multi_match_query, slop=3)
else:
self.__builder.add_multi_match(multi_match_query)
Comment thread
VadimKovalenkoSNF marked this conversation as resolved.

def __process_aggregation(self, query_params):
aggregation = query_params.get(V1_PARAMETERS_LIST.AGGREGATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,33 @@ def add_search_after(
):
super().add_search_after(search_after_value, search_after_id, id_type)

def add_multi_match(self, query):
self.query_body['query']['bool']['must'].append({
'multi_match': {
'query': query,
'fields': [
f'{V1_PARAMETERS_LIST.NAME}^2',
V1_PARAMETERS_LIST.ADDRESS,
V1_PARAMETERS_LIST.DESCRIPTION,
V1_PARAMETERS_LIST.LOCAL_NAME
],
'fuzziness': self.default_fuzziness
def add_multi_match(self, query, slop=None):
fields = [
f'{V1_PARAMETERS_LIST.NAME}^2',
V1_PARAMETERS_LIST.ADDRESS,
V1_PARAMETERS_LIST.DESCRIPTION,
V1_PARAMETERS_LIST.LOCAL_NAME
]

if slop is not None:
multi_match_query = {
'multi_match': {
'query': query,
'fields': fields,
'type': 'phrase',
'slop': slop
}
}
})
else:
multi_match_query = {
'multi_match': {
'query': query,
'fields': fields,
'fuzziness': self.default_fuzziness
}
}

self.query_body['query']['bool']['must'].append(multi_match_query)

def add_aggregations(self, aggregation, geohex_grid_precision=None):
if aggregation == 'geohex_grid':
Expand Down
52 changes: 51 additions & 1 deletion src/tests/opensearch/test_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,54 @@ def test_search_document_with_long_address(self):
index=self.production_locations_index_name,
body=query
)
self.assertGreater(response['hits']['total']['value'], 0)
self.assertEqual(
response['hits']['hits'][0]['_source']['address'],
"Land plot number 115, map sheet number 03, Cadastral map of Son Ha commune, Son Ha commune, Nho Quan district, Ninh Binh province, Vietnam"
)

def test_search_document_with_long_query(self):
doc = {
"sector": ["Apparel"],
"address": "Mount Isa Mines Limited Copper Refineries",
"name": "Copper Refineries Pty Ltd Mount Isa Mines Limited CRL",
"country": {"alpha_2": "AU"},
"os_id": "AU2025093077Q64",
"coordinates": {"lat": -16.940004, "lon": 145.7628965},
"description": "Mount Isa Mines Limited Copper Refineries Pty Ltd CRL",
"local_name": "Mount Isa Mines Limited Copper Refineries Pty Ltd CRL"
}
self.client.index(
index=self.production_locations_index_name,
body=doc,
id=self.client.count()
)
self.client.indices.refresh(index=self.production_locations_index_name)

query_text = "Mount Isa Mines Limited Copper Refineries Pty Ltd CRL"
query = {
'query': {
'bool': {
'must': [
{
'multi_match': {
'query': query_text,
'fields': ['name^3', 'address^2', 'description^2', 'local_name^2'],
'type': 'phrase',
'slop': 2
}
}
],
'filter': [
{'term': {'country.alpha_2': 'AU'}}
]
}
}
}
response = self.client.search(
index=self.production_locations_index_name,
body=query
)
self.assertEqual(
response['hits']['hits'][0]['_source']['address'],
"Mount Isa Mines Limited Copper Refineries"
)