-
Notifications
You must be signed in to change notification settings - Fork 0
/
courses.py
65 lines (63 loc) · 1.53 KB
/
courses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import json
import requests
url = "https://portal.cca.edu/search/courses/_search"
headers = {
"accept": "application/json",
"content-type": "application/json",
}
query = {
# "query": {
# "simple_query_string": {
# "query": "SEARCH TEXT HERE",
# "fields": [
# "title^2",
# "section_code",
# "get_section_description",
# "_get_instructors",
# "get_subject"
# ]
# }
# },
"post_filter": {
"term": {
"get_term_filter": "Spring 2025"
}
},
"size": 10,
"suggest": {
"text": "",
"suggestions": {
"phrase": {
"field": "get_section_description",
"real_word_error_likelihood": 0.95,
"max_errors": 1,
"gram_size": 4,
"direct_generator": [
{
"field": "get_section_description",
"suggest_mode": "always",
"min_word_length": 1
}
]
}
}
},
"sort": [
{
"_score": "desc"
},
{
"get_subject_filter": "asc"
},
{
"get_course_number_filter": "asc"
},
{
"section_number_filter": "asc"
}
]
}
r = requests.post(url, json=query, headers=headers)
r.raise_for_status()
data = r.json()
print(json.dumps(data, indent=2))