From 74ff4e7ef87394a21b835e78b58c97dffd47e6ee Mon Sep 17 00:00:00 2001 From: Anastasia Beglova Date: Wed, 4 Sep 2024 17:12:32 -0400 Subject: [PATCH] dfs_query_then_fetch --- frontends/api/src/generated/v1/api.ts | 101 ++++++++++++++++++ .../SearchDisplay/SearchDisplay.tsx | 1 + learning_resources_search/api.py | 5 +- learning_resources_search/serializers.py | 9 ++ learning_resources_search/serializers_test.py | 3 + openapi/specs/v1.yaml | 46 ++++++++ 6 files changed, 164 insertions(+), 1 deletion(-) diff --git a/frontends/api/src/generated/v1/api.ts b/frontends/api/src/generated/v1/api.ts index db686bf072..821164a00d 100644 --- a/frontends/api/src/generated/v1/api.ts +++ b/frontends/api/src/generated/v1/api.ts @@ -3481,6 +3481,12 @@ export interface PercolateQuerySubscriptionRequestRequest { * @memberof PercolateQuerySubscriptionRequestRequest */ dev_mode?: boolean | null + /** + * If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes + * @type {boolean} + * @memberof PercolateQuerySubscriptionRequestRequest + */ + use_dfs_query_then_fetch?: boolean | null /** * The id value for the learning resource * @type {Array} @@ -6841,6 +6847,7 @@ export const ContentFileSearchApiAxiosParamCreator = function ( * @param {Array} [run_id] The id value of the run that the content file belongs to * @param {ContentFileSearchRetrieveSortbyEnum} [sortby] if the parameter starts with \'-\' the sort is in descending order * `id` - id * `-id` - -id * `resource_readable_id` - resource_readable_id * `-resource_readable_id` - -resource_readable_id * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6858,6 +6865,7 @@ export const ContentFileSearchApiAxiosParamCreator = function ( run_id?: Array, sortby?: ContentFileSearchRetrieveSortbyEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, options: RawAxiosRequestConfig = {}, ): Promise => { const localVarPath = `/api/v1/content_file_search/` @@ -6928,6 +6936,11 @@ export const ContentFileSearchApiAxiosParamCreator = function ( localVarQueryParameter["topic"] = topic } + if (use_dfs_query_then_fetch !== undefined) { + localVarQueryParameter["use_dfs_query_then_fetch"] = + use_dfs_query_then_fetch + } + setSearchParams(localVarUrlObj, localVarQueryParameter) let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {} @@ -6969,6 +6982,7 @@ export const ContentFileSearchApiFp = function (configuration?: Configuration) { * @param {Array} [run_id] The id value of the run that the content file belongs to * @param {ContentFileSearchRetrieveSortbyEnum} [sortby] if the parameter starts with \'-\' the sort is in descending order * `id` - id * `-id` - -id * `resource_readable_id` - resource_readable_id * `-resource_readable_id` - -resource_readable_id * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -6986,6 +7000,7 @@ export const ContentFileSearchApiFp = function (configuration?: Configuration) { run_id?: Array, sortby?: ContentFileSearchRetrieveSortbyEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, options?: RawAxiosRequestConfig, ): Promise< ( @@ -7008,6 +7023,7 @@ export const ContentFileSearchApiFp = function (configuration?: Configuration) { run_id, sortby, topic, + use_dfs_query_then_fetch, options, ) const index = configuration?.serverIndex ?? 0 @@ -7063,6 +7079,7 @@ export const ContentFileSearchApiFactory = function ( requestParameters.run_id, requestParameters.sortby, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, options, ) .then((request) => request(axios, basePath)) @@ -7166,6 +7183,13 @@ export interface ContentFileSearchApiContentFileSearchRetrieveRequest { * @memberof ContentFileSearchApiContentFileSearchRetrieve */ readonly topic?: Array + + /** + * If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes + * @type {boolean} + * @memberof ContentFileSearchApiContentFileSearchRetrieve + */ + readonly use_dfs_query_then_fetch?: boolean | null } /** @@ -7202,6 +7226,7 @@ export class ContentFileSearchApi extends BaseAPI { requestParameters.run_id, requestParameters.sortby, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, options, ) .then((request) => request(this.axios, this.basePath)) @@ -12240,6 +12265,7 @@ export const LearningResourcesSearchApiAxiosParamCreator = function ( * @param {number | null} [slop] Allowed distance for phrase search * @param {LearningResourcesSearchRetrieveSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -12269,6 +12295,7 @@ export const LearningResourcesSearchApiAxiosParamCreator = function ( slop?: number | null, sortby?: LearningResourcesSearchRetrieveSortbyEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, options: RawAxiosRequestConfig = {}, ): Promise => { @@ -12385,6 +12412,11 @@ export const LearningResourcesSearchApiAxiosParamCreator = function ( localVarQueryParameter["topic"] = topic } + if (use_dfs_query_then_fetch !== undefined) { + localVarQueryParameter["use_dfs_query_then_fetch"] = + use_dfs_query_then_fetch + } + if (yearly_decay_percent !== undefined) { localVarQueryParameter["yearly_decay_percent"] = yearly_decay_percent } @@ -12443,6 +12475,7 @@ export const LearningResourcesSearchApiFp = function ( * @param {number | null} [slop] Allowed distance for phrase search * @param {LearningResourcesSearchRetrieveSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -12472,6 +12505,7 @@ export const LearningResourcesSearchApiFp = function ( slop?: number | null, sortby?: LearningResourcesSearchRetrieveSortbyEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, options?: RawAxiosRequestConfig, ): Promise< @@ -12506,6 +12540,7 @@ export const LearningResourcesSearchApiFp = function ( slop, sortby, topic, + use_dfs_query_then_fetch, yearly_decay_percent, options, ) @@ -12573,6 +12608,7 @@ export const LearningResourcesSearchApiFactory = function ( requestParameters.slop, requestParameters.sortby, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, options, ) @@ -12755,6 +12791,13 @@ export interface LearningResourcesSearchApiLearningResourcesSearchRetrieveReques */ readonly topic?: Array + /** + * If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes + * @type {boolean} + * @memberof LearningResourcesSearchApiLearningResourcesSearchRetrieve + */ + readonly use_dfs_query_then_fetch?: boolean | null + /** * Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @type {number} @@ -12808,6 +12851,7 @@ export class LearningResourcesSearchApi extends BaseAPI { requestParameters.slop, requestParameters.sortby, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, options, ) @@ -13045,6 +13089,7 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( * @param {LearningResourcesUserSubscriptionCheckListSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {LearningResourcesUserSubscriptionCheckListSourceTypeEnum} [source_type] The subscription type * `search_subscription_type` - search_subscription_type * `channel_subscription_type` - channel_subscription_type * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -13075,6 +13120,7 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( sortby?: LearningResourcesUserSubscriptionCheckListSortbyEnum, source_type?: LearningResourcesUserSubscriptionCheckListSourceTypeEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, options: RawAxiosRequestConfig = {}, ): Promise => { @@ -13195,6 +13241,11 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( localVarQueryParameter["topic"] = topic } + if (use_dfs_query_then_fetch !== undefined) { + localVarQueryParameter["use_dfs_query_then_fetch"] = + use_dfs_query_then_fetch + } + if (yearly_decay_percent !== undefined) { localVarQueryParameter["yearly_decay_percent"] = yearly_decay_percent } @@ -13240,6 +13291,7 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( * @param {number | null} [slop] Allowed distance for phrase search * @param {LearningResourcesUserSubscriptionListSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -13269,6 +13321,7 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( slop?: number | null, sortby?: LearningResourcesUserSubscriptionListSortbyEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, options: RawAxiosRequestConfig = {}, ): Promise => { @@ -13385,6 +13438,11 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( localVarQueryParameter["topic"] = topic } + if (use_dfs_query_then_fetch !== undefined) { + localVarQueryParameter["use_dfs_query_then_fetch"] = + use_dfs_query_then_fetch + } + if (yearly_decay_percent !== undefined) { localVarQueryParameter["yearly_decay_percent"] = yearly_decay_percent } @@ -13431,6 +13489,7 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( * @param {LearningResourcesUserSubscriptionSubscribeCreateSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {LearningResourcesUserSubscriptionSubscribeCreateSourceTypeEnum} [source_type] The subscription type * `search_subscription_type` - search_subscription_type * `channel_subscription_type` - channel_subscription_type * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {PercolateQuerySubscriptionRequestRequest} [PercolateQuerySubscriptionRequestRequest] * @param {*} [options] Override http request option. @@ -13462,6 +13521,7 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( sortby?: LearningResourcesUserSubscriptionSubscribeCreateSortbyEnum, source_type?: LearningResourcesUserSubscriptionSubscribeCreateSourceTypeEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, PercolateQuerySubscriptionRequestRequest?: PercolateQuerySubscriptionRequestRequest, options: RawAxiosRequestConfig = {}, @@ -13583,6 +13643,11 @@ export const LearningResourcesUserSubscriptionApiAxiosParamCreator = function ( localVarQueryParameter["topic"] = topic } + if (use_dfs_query_then_fetch !== undefined) { + localVarQueryParameter["use_dfs_query_then_fetch"] = + use_dfs_query_then_fetch + } + if (yearly_decay_percent !== undefined) { localVarQueryParameter["yearly_decay_percent"] = yearly_decay_percent } @@ -13700,6 +13765,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( * @param {LearningResourcesUserSubscriptionCheckListSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {LearningResourcesUserSubscriptionCheckListSourceTypeEnum} [source_type] The subscription type * `search_subscription_type` - search_subscription_type * `channel_subscription_type` - channel_subscription_type * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -13730,6 +13796,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( sortby?: LearningResourcesUserSubscriptionCheckListSortbyEnum, source_type?: LearningResourcesUserSubscriptionCheckListSourceTypeEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, options?: RawAxiosRequestConfig, ): Promise< @@ -13765,6 +13832,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( sortby, source_type, topic, + use_dfs_query_then_fetch, yearly_decay_percent, options, ) @@ -13808,6 +13876,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( * @param {number | null} [slop] Allowed distance for phrase search * @param {LearningResourcesUserSubscriptionListSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -13837,6 +13906,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( slop?: number | null, sortby?: LearningResourcesUserSubscriptionListSortbyEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, options?: RawAxiosRequestConfig, ): Promise< @@ -13871,6 +13941,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( slop, sortby, topic, + use_dfs_query_then_fetch, yearly_decay_percent, options, ) @@ -13915,6 +13986,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( * @param {LearningResourcesUserSubscriptionSubscribeCreateSortbyEnum} [sortby] If the parameter starts with \'-\' the sort is in descending order * `featured` - Featured * `id` - Object ID ascending * `-id` - Object ID descending * `readable_id` - Readable ID ascending * `-readable_id` - Readable ID descending * `last_modified` - Last Modified Date ascending * `-last_modified` - Last Modified Date descending * `new` - Newest resources first * `start_date` - Start Date ascending * `-start_date` - Start Date descending * `mitcoursenumber` - MIT course number ascending * `-mitcoursenumber` - MIT course number descending * `views` - Popularity ascending * `-views` - Popularity descending * `upcoming` - Next start date ascending * @param {LearningResourcesUserSubscriptionSubscribeCreateSourceTypeEnum} [source_type] The subscription type * `search_subscription_type` - search_subscription_type * `channel_subscription_type` - channel_subscription_type * @param {Array} [topic] The topic name. To see a list of options go to api/v1/topics/ + * @param {boolean | null} [use_dfs_query_then_fetch] If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes * @param {number | null} [yearly_decay_percent] Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @param {PercolateQuerySubscriptionRequestRequest} [PercolateQuerySubscriptionRequestRequest] * @param {*} [options] Override http request option. @@ -13946,6 +14018,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( sortby?: LearningResourcesUserSubscriptionSubscribeCreateSortbyEnum, source_type?: LearningResourcesUserSubscriptionSubscribeCreateSourceTypeEnum, topic?: Array, + use_dfs_query_then_fetch?: boolean | null, yearly_decay_percent?: number | null, PercolateQuerySubscriptionRequestRequest?: PercolateQuerySubscriptionRequestRequest, options?: RawAxiosRequestConfig, @@ -13979,6 +14052,7 @@ export const LearningResourcesUserSubscriptionApiFp = function ( sortby, source_type, topic, + use_dfs_query_then_fetch, yearly_decay_percent, PercolateQuerySubscriptionRequestRequest, options, @@ -14079,6 +14153,7 @@ export const LearningResourcesUserSubscriptionApiFactory = function ( requestParameters.sortby, requestParameters.source_type, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, options, ) @@ -14121,6 +14196,7 @@ export const LearningResourcesUserSubscriptionApiFactory = function ( requestParameters.slop, requestParameters.sortby, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, options, ) @@ -14164,6 +14240,7 @@ export const LearningResourcesUserSubscriptionApiFactory = function ( requestParameters.sortby, requestParameters.source_type, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, requestParameters.PercolateQuerySubscriptionRequestRequest, options, @@ -14372,6 +14449,13 @@ export interface LearningResourcesUserSubscriptionApiLearningResourcesUserSubscr */ readonly topic?: Array + /** + * If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes + * @type {boolean} + * @memberof LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionCheckList + */ + readonly use_dfs_query_then_fetch?: boolean | null + /** * Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @type {number} @@ -14554,6 +14638,13 @@ export interface LearningResourcesUserSubscriptionApiLearningResourcesUserSubscr */ readonly topic?: Array + /** + * If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes + * @type {boolean} + * @memberof LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionList + */ + readonly use_dfs_query_then_fetch?: boolean | null + /** * Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @type {number} @@ -14743,6 +14834,13 @@ export interface LearningResourcesUserSubscriptionApiLearningResourcesUserSubscr */ readonly topic?: Array + /** + * If true sets search_type=dfs_query_then_fetch which makes Opensearchmake an extra pre-query to calculate term frequencies accross indexes + * @type {boolean} + * @memberof LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionSubscribeCreate + */ + readonly use_dfs_query_then_fetch?: boolean | null + /** * Relevance score penalty percent per year for for resources without upcoming runs. Only affects results if there is a search term. * @type {number} @@ -14818,6 +14916,7 @@ export class LearningResourcesUserSubscriptionApi extends BaseAPI { requestParameters.sortby, requestParameters.source_type, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, options, ) @@ -14862,6 +14961,7 @@ export class LearningResourcesUserSubscriptionApi extends BaseAPI { requestParameters.slop, requestParameters.sortby, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, options, ) @@ -14907,6 +15007,7 @@ export class LearningResourcesUserSubscriptionApi extends BaseAPI { requestParameters.sortby, requestParameters.source_type, requestParameters.topic, + requestParameters.use_dfs_query_then_fetch, requestParameters.yearly_decay_percent, requestParameters.PercolateQuerySubscriptionRequestRequest, options, diff --git a/frontends/mit-learn/src/page-components/SearchDisplay/SearchDisplay.tsx b/frontends/mit-learn/src/page-components/SearchDisplay/SearchDisplay.tsx index 7e0d8e8299..4943b9ae7f 100644 --- a/frontends/mit-learn/src/page-components/SearchDisplay/SearchDisplay.tsx +++ b/frontends/mit-learn/src/page-components/SearchDisplay/SearchDisplay.tsx @@ -553,6 +553,7 @@ const SearchDisplay: React.FC = ({ 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", diff --git a/learning_resources_search/api.py b/learning_resources_search/api.py index 8310029564..f377f832c2 100644 --- a/learning_resources_search/api.py +++ b/learning_resources_search/api.py @@ -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 @@ -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 diff --git a/learning_resources_search/serializers.py b/learning_resources_search/serializers.py index eca76c484f..bcdc4829a5 100644 --- a/learning_resources_search/serializers.py +++ b/learning_resources_search/serializers.py @@ -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) diff --git a/learning_resources_search/serializers_test.py b/learning_resources_search/serializers_test.py index ba801d4a1b..9d09f6c0d3 100644 --- a/learning_resources_search/serializers_test.py +++ b/learning_resources_search/serializers_test.py @@ -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 = { @@ -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) @@ -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) diff --git a/openapi/specs/v1.yaml b/openapi/specs/v1.yaml index 8c71a39812..4c1e3ab103 100644 --- a/openapi/specs/v1.yaml +++ b/openapi/specs/v1.yaml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: