Skip to content

Commit bc71b04

Browse files
committed
Search by department id instead of name
1 parent 95f4d01 commit bc71b04

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ services:
3434
image: opensearchproject/opensearch:1.3.11
3535
container_name: opensearch-node-mitopen
3636
environment:
37-
- http.max_content_length=10mb
3837
- cluster.name=opensearch-cluster
3938
- node.name=opensearch-node-mitopen
4039
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping

learning_resources_search/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ def generate_sort_clause(search_params):
9797
"filter": {
9898
"bool": {
9999
"should": [
100-
{"term": {f"{path}.department.name": department}}
100+
{
101+
"term": {
102+
f"{path}.department.department_id": department
103+
}
104+
}
101105
for department in departments
102106
]
103107
}

learning_resources_search/api_test.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def test_relevant_indexes(resourse_types, aggregations, result):
3636
("sort_param", "departments", "result"),
3737
[
3838
("id", None, "id"),
39-
("-id", ["Biology"], "-id"),
39+
("-id", ["7"], "-id"),
4040
(
4141
"start_date",
42-
["Chemistry"],
42+
["5"],
4343
{"runs.start_date": {"order": "asc", "nested": {"path": "runs"}}},
4444
),
4545
(
@@ -62,7 +62,7 @@ def test_relevant_indexes(resourse_types, aggregations, result):
6262
),
6363
(
6464
"mitcoursenumber",
65-
["Biology", "Chemistry"],
65+
["7", "5"],
6666
{
6767
"course.course_numbers.sort_coursenum": {
6868
"order": "asc",
@@ -73,15 +73,15 @@ def test_relevant_indexes(resourse_types, aggregations, result):
7373
"should": [
7474
{
7575
"term": {
76-
"course.course_numbers.department.name": (
77-
"Biology"
76+
"course.course_numbers.department.department_id": (
77+
"7"
7878
)
7979
}
8080
},
8181
{
8282
"term": {
83-
"course.course_numbers.department.name": (
84-
"Chemistry"
83+
"course.course_numbers.department.department_id": (
84+
"5"
8585
)
8686
}
8787
},
@@ -141,7 +141,9 @@ def test_generate_learning_resources_text_clause():
141141
"query": {
142142
"multi_match": {
143143
"query": "math",
144-
"fields": ["departments.name"],
144+
"fields": [
145+
"departments.department_id"
146+
],
145147
}
146148
},
147149
}
@@ -256,7 +258,7 @@ def test_generate_learning_resources_text_clause():
256258
"query": {
257259
"multi_match": {
258260
"query": "math",
259-
"fields": ["departments.name"],
261+
"fields": ["departments.department_id"],
260262
}
261263
},
262264
}
@@ -371,7 +373,9 @@ def test_generate_learning_resources_text_clause():
371373
"query": {
372374
"query_string": {
373375
"query": '"math"',
374-
"fields": ["departments.name"],
376+
"fields": [
377+
"departments.department_id"
378+
],
375379
}
376380
},
377381
}
@@ -489,7 +493,7 @@ def test_generate_learning_resources_text_clause():
489493
"query": {
490494
"query_string": {
491495
"query": '"math"',
492-
"fields": ["departments.name"],
496+
"fields": ["departments.department_id"],
493497
}
494498
},
495499
}
@@ -593,7 +597,9 @@ def test_generate_content_file_text_clause():
593597
"query": {
594598
"multi_match": {
595599
"query": "math",
596-
"fields": ["departments.name"],
600+
"fields": [
601+
"departments.department_id"
602+
],
597603
}
598604
},
599605
}
@@ -622,7 +628,7 @@ def test_generate_content_file_text_clause():
622628
"query": {
623629
"multi_match": {
624630
"query": "math",
625-
"fields": ["departments.name"],
631+
"fields": ["departments.department_id"],
626632
}
627633
},
628634
}
@@ -655,7 +661,9 @@ def test_generate_content_file_text_clause():
655661
"query": {
656662
"query_string": {
657663
"query": '"math"',
658-
"fields": ["departments.name"],
664+
"fields": [
665+
"departments.department_id"
666+
],
659667
}
660668
},
661669
}
@@ -684,7 +692,7 @@ def test_generate_content_file_text_clause():
684692
"query": {
685693
"query_string": {
686694
"query": '"math"',
687-
"fields": ["departments.name"],
695+
"fields": ["departments.department_id"],
688696
}
689697
},
690698
}
@@ -905,7 +913,7 @@ def test_execute_learn_search(opensearch):
905913
"multi_match": {
906914
"query": "math",
907915
"fields": [
908-
"departments.name"
916+
"departments.department_id"
909917
],
910918
}
911919
},
@@ -1027,7 +1035,7 @@ def test_execute_learn_search(opensearch):
10271035
"query": {
10281036
"multi_match": {
10291037
"query": "math",
1030-
"fields": ["departments.name"],
1038+
"fields": ["departments.department_id"],
10311039
}
10321040
},
10331041
}

learning_resources_search/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class IndexestoUpdate(Enum):
5858
SEARCH_NESTED_FILTERS = {
5959
"topic": "topics.name",
6060
"level": "runs.level",
61-
"department": "departments.name",
61+
"department": "departments.department_id",
6262
}
6363

6464
ENGLISH_TEXT_FIELD = {
@@ -214,7 +214,7 @@ class IndexestoUpdate(Enum):
214214
]
215215

216216
TOPICS_QUERY_FIELDS = ["topics.name"]
217-
DEPARTMENT_QUERY_FIELDS = ["departments.name"]
217+
DEPARTMENT_QUERY_FIELDS = ["departments.department_id"]
218218

219219
COURSE_QUERY_FIELDS = [
220220
"course.course_numbers.value",

learning_resources_search/serializers_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_learning_resources_search_request_serializer():
199199
"offered_by": "xpro,ocw",
200200
"platform": "xpro,edx,ocw",
201201
"topic": "Math",
202-
"department": "mathematics,chemistry",
202+
"department": "18,5",
203203
"level": "Undergraduate",
204204
"resource_content_tags": "Lecture Videos",
205205
"aggregations": "resource_type,platform,level",
@@ -217,7 +217,7 @@ def test_learning_resources_search_request_serializer():
217217
"offered_by": ["xpro", "ocw"],
218218
"platform": ["xpro", "edx", "ocw"],
219219
"topic": ["Math"],
220-
"department": ["mathematics", "chemistry"],
220+
"department": ["18", "5"],
221221
"level": ["Undergraduate"],
222222
"resource_content_tags": ["Lecture Videos"],
223223
"aggregations": ["resource_type", "platform", "level"],

0 commit comments

Comments
 (0)