Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ def course_discovery_search(search_term=None, size=20, from_=0, field_dictionary
if getattr(settings, 'ALLOW_CATALOG_VISIBILITY_FILTER', False):
use_field_dictionary['catalog_visibility'] = CATALOG_VISIBILITY_CATALOG_AND_ABOUT

course_tag_list = kwargs.get('course_tag_list', [])

results = searcher.search(
query_string=search_term,
doc_type="course_info",
Expand All @@ -271,6 +273,7 @@ def course_discovery_search(search_term=None, size=20, from_=0, field_dictionary
filter_dictionary=filter_dictionary,
exclude_dictionary=exclude_dictionary,
facet_terms=course_discovery_facets(),
course_tag_list=course_tag_list,
sort=sort_args
)

Expand Down
9 changes: 8 additions & 1 deletion search/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ def search(self,
filter_dictionary=None,
exclude_dictionary=None,
facet_terms=None,
course_tag_list=None,
exclude_ids=None,
use_field_match=False,
include_content=False,
Expand Down Expand Up @@ -640,6 +641,11 @@ def search(self,
"analyzer": "standard"
}
})
elastic_queries.append({
"terms": {
"tag": course_tag_list
}
})

if field_dictionary:
if use_field_match:
Expand Down Expand Up @@ -667,7 +673,7 @@ def search(self,
if elastic_queries:
query_segment = {
"bool": {
"must": elastic_queries
"should": elastic_queries
}
}

Expand Down Expand Up @@ -698,6 +704,7 @@ def search(self,
body=body,
**kwargs
)
log.info("search es_response: %s", es_response)
except exceptions.ElasticsearchException as ex:
message = unicode(ex)
if 'QueryParsingException' in message:
Expand Down
5 changes: 5 additions & 0 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ def course_discovery(request):

search_term = request.POST.get("search_string", None)

# Search tag by input with the course search
# course_tag_list_string = request.POST.get("course_tag_list_string", '')
# course_tag_list = course_tag_list_string.split(', ')

try:
size, from_, page = _process_pagination_values(request)
field_dictionary = _course_process_field_values(request)
Expand All @@ -228,6 +232,7 @@ def course_discovery(request):
from_=from_,
field_dictionary=field_dictionary,
user=request.user,
# course_tag_list=course_tag_list,
allow_enrollment_end_filter=True,
sort_type=request.POST.get('sort_type', '')
)
Expand Down