Skip to content
Merged
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
101 changes: 101 additions & 0 deletions frontends/api/src/generated/v1/api.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ const SearchDisplay: React.FC<SearchDisplayProps> = ({
max_incompleteness_penalty: searchParams.get(
"max_incompleteness_penalty",
),
use_dfs_query_then_fetch: searchParams.get("use_dfs_query_then_fetch"),
...requestParams,
aggregations: (facetNames || []).concat([
"resource_category",
Expand Down
5 changes: 4 additions & 1 deletion learning_resources_search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def add_text_query_to_search(search, text, search_params, query_type_query):
return search


def construct_search(search_params):
def construct_search(search_params): # noqa: C901
"""
Construct a learning resources search based on the query

Expand Down Expand Up @@ -669,6 +669,9 @@ def construct_search(search_params):
if search_params.get("dev_mode"):
search = search.extra(explain=True)

if search_params.get("use_dfs_query_then_fetch"):
search = search.params(search_type="dfs_query_then_fetch")

return search


Expand Down
9 changes: 9 additions & 0 deletions learning_resources_search/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ class SearchRequestSerializer(serializers.Serializer):
default=False,
help_text="If true return raw open search results with score explanations",
)
use_dfs_query_then_fetch = serializers.BooleanField(
required=False,
allow_null=True,
default=False,
help_text=(
"If true sets search_type=dfs_query_then_fetch which makes Opensearch"
"make an extra pre-query to calculate term frequencies accross indexes"
),
)

def validate(self, attrs):
unknown = set(self.initial_data) - set(self.fields)
Expand Down
3 changes: 3 additions & 0 deletions learning_resources_search/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ def test_learning_resources_search_request_serializer():
"slop": 2,
"min_score": 0,
"max_incompleteness_penalty": 25,
"use_dfs_query_then_fetch": False,
}

cleaned = {
Expand All @@ -905,6 +906,7 @@ def test_learning_resources_search_request_serializer():
"slop": 2,
"min_score": 0,
"max_incompleteness_penalty": 25,
"use_dfs_query_then_fetch": False,
}

serialized = LearningResourcesSearchRequestSerializer(data=data)
Expand Down Expand Up @@ -942,6 +944,7 @@ def test_content_file_search_request_serializer():
"offered_by": ["xpro", "ocw"],
"platform": ["xpro", "edx", "ocw"],
"dev_mode": False,
"use_dfs_query_then_fetch": False,
}

serialized = ContentFileSearchRequestSerializer(data=data)
Expand Down
46 changes: 46 additions & 0 deletions openapi/specs/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ paths:
type: string
minLength: 1
description: The topic name. To see a list of options go to api/v1/topics/
- in: query
name: use_dfs_query_then_fetch
schema:
type: boolean
nullable: true
default: false
description: If true sets search_type=dfs_query_then_fetch which makes Opensearchmake
an extra pre-query to calculate term frequencies accross indexes
tags:
- content_file_search
responses:
Expand Down Expand Up @@ -2674,6 +2682,14 @@ paths:
type: string
minLength: 1
description: The topic name. To see a list of options go to api/v1/topics/
- in: query
name: use_dfs_query_then_fetch
schema:
type: boolean
nullable: true
default: false
description: If true sets search_type=dfs_query_then_fetch which makes Opensearchmake
an extra pre-query to calculate term frequencies accross indexes
- in: query
name: yearly_decay_percent
schema:
Expand Down Expand Up @@ -3155,6 +3171,14 @@ paths:
type: string
minLength: 1
description: The topic name. To see a list of options go to api/v1/topics/
- in: query
name: use_dfs_query_then_fetch
schema:
type: boolean
nullable: true
default: false
description: If true sets search_type=dfs_query_then_fetch which makes Opensearchmake
an extra pre-query to calculate term frequencies accross indexes
- in: query
name: yearly_decay_percent
schema:
Expand Down Expand Up @@ -3675,6 +3699,14 @@ paths:
type: string
minLength: 1
description: The topic name. To see a list of options go to api/v1/topics/
- in: query
name: use_dfs_query_then_fetch
schema:
type: boolean
nullable: true
default: false
description: If true sets search_type=dfs_query_then_fetch which makes Opensearchmake
an extra pre-query to calculate term frequencies accross indexes
- in: query
name: yearly_decay_percent
schema:
Expand Down Expand Up @@ -4172,6 +4204,14 @@ paths:
type: string
minLength: 1
description: The topic name. To see a list of options go to api/v1/topics/
- in: query
name: use_dfs_query_then_fetch
schema:
type: boolean
nullable: true
default: false
description: If true sets search_type=dfs_query_then_fetch which makes Opensearchmake
an extra pre-query to calculate term frequencies accross indexes
- in: query
name: yearly_decay_percent
schema:
Expand Down Expand Up @@ -9835,6 +9875,12 @@ components:
nullable: true
default: false
description: If true return raw open search results with score explanations
use_dfs_query_then_fetch:
type: boolean
nullable: true
default: false
description: If true sets search_type=dfs_query_then_fetch which makes Opensearchmake
an extra pre-query to calculate term frequencies accross indexes
id:
type: array
items:
Expand Down