Search index refresh in Joplin CLI server

Search result from API is stale after sync #11631

Hi all,
I have been looking into this issue and to solve the issue , we can either :

  1. trigger sync every time in the search API call or
  2. update index of search engine, every time a update is done in Jupiter server

I would appreciate if I can be given some guidance to start working on this issue.

Hello,

I have been looking into this issue as my first contribution to Joplin.

I could make out following in this issue :

  1. when we create a "REST API server Joplin" using cli client by
    joplin --profile /joplin/profile server start,
    we have started first instance/process of joplin

  2. and later when we call "sync" command on the CLI client using
    joplin --profile /joplin/profile sync
    it creates another instance of Joplin which is sharing the same profile.

now if we were using TUI or GUI joplin, searchengine scheduler would have rebuilt index after sometime as suggest by laurent in earlier reply quoted as follows :

The search engine would need to index the note first, and I don't think that can be triggered via CLI. You'd need to start the TUI and let it run for some time, a few seconds probably, until indexing is done

However, CLI client executing "sync" command exits before the searchengine scheduler could be triggered to reindex notes. Hence, searchengine index in "REST API server Joplin" is stale and is unable to find newly added notes in search api call

Therefore for the solution, we can call this function public async syncTables() after the sync is finished, it ensures that searchindex is refreshed. We will need to add this in Command_sync.ts present in app-cli.

Further we may not need to the handle changes made by REST API manually as these changes will be handled by searchengine scheduler running in same instance of Joplin which is receiving REST API calls unlike the changes by "sync" command made in a Joplin instance different than "REST API server Joplin".

Please comment if I have understood the problem and also if solution suggested to trigger reindexing in sync command itself makes sense in this case.

Thanks.