55import { StatusCodes } from "http-status-codes" ;
66
77import {
8+ CLP_QUERY_ENGINES ,
89 SEARCH_SIGNAL ,
910 type SearchResultsMetadataDocument ,
1011} from "../../../../../common/index.js" ;
@@ -18,7 +19,6 @@ import {QUERY_JOB_TYPE} from "../../../typings/query.js";
1819import { SEARCH_MAX_NUM_RESULTS } from "./typings.js" ;
1920import {
2021 createMongoIndexes ,
21- updateSearchResultsMeta ,
2222 updateSearchSignalWhenJobsFinish ,
2323} from "./utils.js" ;
2424
@@ -44,6 +44,8 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
4444 settings . MongoDbSearchResultsMetadataCollectionName
4545 ) ;
4646
47+ const queryEngine = settings . ClpQueryEngine as CLP_QUERY_ENGINES ;
48+
4749 /**
4850 * Submits a search query and initiates the search process.
4951 */
@@ -113,6 +115,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
113115 _id : searchJobId . toString ( ) ,
114116 lastSignal : SEARCH_SIGNAL . RESP_QUERYING ,
115117 errorMsg : null ,
118+ queryEngine : queryEngine ,
116119 } ) ;
117120
118121 // Defer signal update until after response is sent
@@ -197,16 +200,18 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
197200 await QueryJobDbManager . cancelJob ( searchJobId ) ;
198201 await QueryJobDbManager . cancelJob ( aggregationJobId ) ;
199202
200- await updateSearchResultsMeta ( {
201- fields : {
202- lastSignal : SEARCH_SIGNAL . RESP_DONE ,
203- errorMsg : "Query cancelled before it could be completed." ,
203+ await searchResultsMetadataCollection . updateOne (
204+ {
205+ _id : searchJobId . toString ( ) ,
206+ lastSignal : SEARCH_SIGNAL . RESP_QUERYING ,
204207 } ,
205- jobId : searchJobId ,
206- lastSignal : SEARCH_SIGNAL . RESP_QUERYING ,
207- logger : request . log ,
208- searchResultsMetadataCollection : searchResultsMetadataCollection ,
209- } ) ;
208+ {
209+ $set : {
210+ lastSignal : SEARCH_SIGNAL . RESP_DONE ,
211+ errorMsg : "Query cancelled before it could be completed." ,
212+ } ,
213+ }
214+ ) ;
210215 } catch ( err : unknown ) {
211216 const errMsg = "Failed to submit cancel request" ;
212217 request . log . error (
0 commit comments