# Advance search in queue

**URL:** <https://pdfjs.community/t/advance-search-in-queue/3128>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [February 13, 2024, 4:31pm UTC](https://pdfjs.community/t/advance-search-in-queue/3128 "2024-02-13T16:31:27Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![hthiru](https://avatars.discourse-cdn.com/v4/letter/h/f4b2a3/32.png) [@hthiru](https://pdfjs.community/u/hthiru)\
**Post date:** [February 15, 2024, 10:20pm UTC](https://pdfjs.community/t/advance-search-in-queue/3128/5 "2024-02-15T22:20:41Z")

</div>

HI Tyler,  
Sorry I could not share the file.

Can I trigger textSearchInit in parallel instead of synchronously?

> [@Executing TextSearchInit multiple times](https://pdfjs.community/t/executing-textsearchinit-multiple-times/712/6):
>
> ```javascript
> const queue = ['pdf', 'viewer'];
> 
> function drawAnnotations() {
> if (queue && queue.length) {
> let chain = Promise.resolve();
> for (const nextAnnotation of queue) {
> chain = chain.then(() => {
> return drawAnnotation(nextAnnotation)
> })
> }
> }
> }
>   
> function drawAnnotation(phrase) {
> return new Promise(resolve => {
> console.log('drawAnnotation(): ' + phrase);
>       
> const searchMode = CoreControls.Search.Mode.HIGHLIGHT;
>     
> const searchOptions = {
> fullSearch: true,
> onResult: (result) => {
> if (result.resultCode === CoreControls.Search.ResultCode.FOUND) {
> console.log('onResult: ' + result);
> }
> },
> onDocumentEnd: (result) => {
> resolve();
> }
> }
>     
> docViewer.textSearchInit(phrase, searchMode, searchOptions);
> 
> })
> 
> }
> 
> drawAnnotations();
> 
> ```

---

_[View the full topic](https://pdfjs.community/t/advance-search-in-queue/3128)._
