@@ -276,6 +276,79 @@ for (s in similar$similar_concepts) {
276276}
277277cat(" \n " )
278278
279+ # ============================================================================
280+ # Bulk Lexical Search
281+ # ============================================================================
282+
283+ cat(" 11. Bulk lexical search (multiple queries in one call)\n " )
284+ cat(" ------------------------------------------------------\n " )
285+
286+ # Search for multiple terms at once (up to 50)
287+ results <- client $ search $ bulk_basic(list (
288+ list (search_id = " q1" , query = " diabetes mellitus" ),
289+ list (search_id = " q2" , query = " hypertension" ),
290+ list (search_id = " q3" , query = " aspirin" )
291+ ), defaults = list (vocabulary_ids = list (" SNOMED" ), page_size = 3 ))
292+
293+ cat(" Bulk search results:\n " )
294+ for (item in results $ results ) {
295+ cat(sprintf(" %s: %d results (%s)\n " ,
296+ item $ search_id , length(item $ results ), item $ status ))
297+ }
298+ cat(" \n " )
299+
300+ # ============================================================================
301+ # Bulk Semantic Search
302+ # ============================================================================
303+
304+ cat(" 12. Bulk semantic search (multiple NLP queries)\n " )
305+ cat(" ------------------------------------------------\n " )
306+
307+ # Search for multiple natural-language queries at once (up to 25)
308+ results <- client $ search $ bulk_semantic(list (
309+ list (search_id = " s1" , query = " heart failure treatment options" ),
310+ list (search_id = " s2" , query = " type 2 diabetes medication" ),
311+ list (search_id = " s3" , query = " elevated blood pressure" )
312+ ), defaults = list (threshold = 0.5 , page_size = 5 ))
313+
314+ cat(" Bulk semantic results:\n " )
315+ for (item in results $ results ) {
316+ n_results <- item $ result_count %|| % length(item $ results )
317+ cat(sprintf(" %s: %d results (%s)\n " ,
318+ item $ search_id , n_results , item $ status ))
319+
320+ # Show top result for each query
321+ if (length(item $ results ) > 0 ) {
322+ top <- item $ results [[1 ]]
323+ cat(sprintf(" Top: %s (score: %.2f)\n " ,
324+ top $ concept_name , top $ similarity_score ))
325+ }
326+ }
327+ cat(" \n " )
328+
329+ # ============================================================================
330+ # Bulk Search with Per-Query Overrides
331+ # ============================================================================
332+
333+ cat(" 13. Bulk search with per-query filters\n " )
334+ cat(" --------------------------------------\n " )
335+
336+ # Defaults apply to all, but individual searches can override
337+ results <- client $ search $ bulk_basic(list (
338+ list (search_id = " conditions" , query = " diabetes" , domain_ids = list (" Condition" )),
339+ list (search_id = " drugs" , query = " metformin" , domain_ids = list (" Drug" ))
340+ ), defaults = list (vocabulary_ids = list (" SNOMED" , " RxNorm" ), page_size = 3 ))
341+
342+ for (item in results $ results ) {
343+ cat(sprintf(" %s:\n " , item $ search_id ))
344+ for (c in item $ results ) {
345+ cat(sprintf(" [%d] %s (%s/%s)\n " ,
346+ c $ concept_id , c $ concept_name ,
347+ c $ vocabulary_id , c $ domain_id ))
348+ }
349+ }
350+ cat(" \n " )
351+
279352# ============================================================================
280353# Done
281354# ============================================================================
0 commit comments