# 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:** 5\
**Page:** 1

<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 13, 2024, 4:31pm UTC](https://pdfjs.community/t/advance-search-in-queue/3128/1 "2024-02-13T16:31:27Z")

</div>

**Which product are you using?**  
PDF.js Express Viewer

**PDF.js Express Version**  
8.10

**Detailed description of issue**  
To copy all the annotaions from version document to another version document.

My document contains nearly 500- 1000 annotaions and mapping them using the advance search functionality taking almost 1hr.  
Is there away to make this process fast.

---

<div class="post-metadata">

**Author:** ![ejohnson](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@ejohnson](https://pdfjs.community/u/ejohnson)\
**Post date:** [February 13, 2024, 6:10pm UTC](https://pdfjs.community/t/advance-search-in-queue/3128/3 "2024-02-13T18:10:50Z")

</div>

Thank you for posting your question to our forum. We will provide you with an update as soon as possible.

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [February 15, 2024, 7:05pm UTC](https://pdfjs.community/t/advance-search-in-queue/3128/4 "2024-02-15T19:05:34Z")

</div>

Hello hthiru,

Can you provide a sample file for us to test with?

Best regards,  
Tyler

---

<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();
> 
> ```

---

<div class="post-metadata">

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

</div>

Hello hthiru,

If you modify to call the `drawAnnotations()` in parallel, does this work for you?

Best regards,  
Tyler
