Skip to content

Commit

Permalink
Search in Planning should recognise CVs case insensitive and not only…
Browse files Browse the repository at this point in the history
… the name field but also the translations [SDBELGA-816]] (#2010)

* update event subject schema to use analyzer and translations [SDBELGA-818]

* use dynamic property in schema

* address comment

* add tests

* update planning subject schema

* Refactored code and minor changes

* remove unwanted code
  • Loading branch information
devketanpro authored Jul 3, 2024
1 parent 8be3513 commit d010b54
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
44 changes: 43 additions & 1 deletion server/features/search_events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: Event Search
"start": "2016-01-02T00:00:00+0000",
"end": "2016-01-03T00:00:00+0000"
},
"subject": [{"qcode": "test qcode 2", "name": "test name"}],
"subject": [{"qcode": "test qcode 2", "name": "test name", "translations": {"name": {"nl": "NL TEST"}}}],
"location": [{"qcode": "test qcode", "name": "test name"}],
"calendars": [
{"qcode": "entertainment", "name": "entertainment"}
Expand Down Expand Up @@ -223,6 +223,48 @@ Feature: Event Search
When we get "/events_planning_search?repo=events&only_future=false&priority=1"
Then we get list with 0 items

When we get "/events_planning_search?repo=events&only_future=false&full_text=test name"
Then we get list with 3 items
"""
{"_items": [
{"_id": "event_123"},
{"_id": "event_456"},
{"_id": "event_786"}
]}
"""
When we get "/events_planning_search?repo=events&only_future=false&full_text=TEST NAME"
Then we get list with 3 items
"""
{"_items": [
{"_id": "event_123"},
{"_id": "event_456"},
{"_id": "event_786"}
]}
"""
When we get "/events_planning_search?repo=events&only_future=false&full_text=Test Name"
Then we get list with 3 items
"""
{"_items": [
{"_id": "event_123"},
{"_id": "event_456"},
{"_id": "event_786"}
]}
"""
When we get "/events_planning_search?repo=events&only_future=false&full_text=NL TEST"
Then we get list with 1 items
"""
{"_items": [
{"_id": "event_456"}
]}
"""
When we get "/events_planning_search?repo=events&only_future=false&full_text=nl test"
Then we get list with 1 items
"""
{"_items": [
{"_id": "event_456"}
]}
"""

@auth
Scenario: Search by event specific parameters
When we get "/events_planning_search?repo=events&only_future=false&slugline=test1%20OR%20test2"
Expand Down
2 changes: 1 addition & 1 deletion server/planning/events/events_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"mapping": {"properties": {"qcode": not_analyzed, "name": not_analyzed}},
},
# Content metadata
"subject": metadata_schema["subject"],
"subject": planning_schema["subject"],
"slugline": metadata_schema["slugline"],
# Item metadata
"location": {
Expand Down
23 changes: 22 additions & 1 deletion server/planning/planning/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,28 @@ def _iter_recurring_plannings_to_update(self, updates, original, update_method):
"description_text": metadata_schema["description_text"],
"internal_note": {"type": "string", "nullable": True},
"anpa_category": metadata_schema["anpa_category"],
"subject": metadata_schema["subject"],
"subject": {
"type": "list",
"mapping": {
"type": "object",
"dynamic": False,
"properties": {
"qcode": not_analyzed,
"name": {
"type": "keyword",
"fields": {
"analyzed": string_with_analyzer,
},
},
"scheme": not_analyzed,
"translations": {
"type": "object",
"dynamic": False,
"properties": {"name": {"type": "object", "dynamic": True}},
},
},
},
},
"genre": metadata_schema["genre"],
"company_codes": metadata_schema["company_codes"],
# Content Metadata - See IPTC-G2-Implementation_Guide 16.2
Expand Down

0 comments on commit d010b54

Please sign in to comment.