Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDBELGA-816] Search in Planning should recognise CVs case insensitive and not only the name field but also the translations #2010

Merged
merged 9 commits into from
Jul 3, 2024
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
27 changes: 25 additions & 2 deletions server/planning/events/events_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# at https://www.sourcefabric.org/superdesk/license

from superdesk import Resource
from superdesk.resource import not_analyzed, not_enabled
from superdesk.resource import not_analyzed, not_enabled, string_with_analyzer
from superdesk.metadata.item import metadata_schema, ITEM_TYPE
from copy import deepcopy

Expand Down Expand Up @@ -195,7 +195,30 @@
"mapping": {"properties": {"qcode": not_analyzed, "name": not_analyzed}},
},
# Content metadata
"subject": metadata_schema["subject"],
"subject": {
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
"type": "list",
"mapping": {
"type": "nested",
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
"include_in_parent": True,
"dynamic": False,
"properties": {
"qcode": not_analyzed,
"name": {
"type": "string",
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
"fields": {
"raw": not_analyzed,
"analyzed": string_with_analyzer,
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
},
},
"scheme": not_analyzed,
"translations": {
"type": "object",
"dynamic": False,
"properties": {"name": {"type": "object", "dynamic": True}},
},
},
},
},
"slugline": metadata_schema["slugline"],
# Item metadata
"location": {
Expand Down
25 changes: 24 additions & 1 deletion server/planning/planning/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,30 @@ 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": {
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
"type": "list",
"mapping": {
"type": "nested",
"include_in_parent": True,
"dynamic": False,
"properties": {
"qcode": not_analyzed,
"name": {
"type": "string",
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
"fields": {
"raw": not_analyzed,
"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
Loading