Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRD-525] [PRD-956] Rely on PouchDB for search #3

Merged
merged 5 commits into from
Oct 21, 2024
Merged

Conversation

paultranvan
Copy link
Contributor

Rather than building the search based on costful stack queries, we now rely on local PouchDB.
When the DataProxy is setup, the replication is triggered for all searchable doctypes. Once it is done, the search indexes are built based on the local database.
To update the index, we rely on realtime: each create/update/delete event is subsribed, and the index is updated accordingly. Then, the replication is triggered in order to replicate changes in PouchDB.

We set up a PouchDB database to replicate doctypes on build the
flexsearch indexes based on it.
Based on the `pouchlink:doctypesync:end` emitted by cozy-pouch-link
after each replication, we are able to update the search indexes through
the changes API.
For any change on listened doctypes, the realtime allows us to
dynamically update the related search index.
@paultranvan paultranvan changed the title Rely on PouchDB for search [PRD-525] Rely on PouchDB for search Oct 18, 2024
@paultranvan paultranvan force-pushed the with-pouch2 branch 2 times, most recently from b4043d9 to fef5ee2 Compare October 18, 2024 11:54
@paultranvan paultranvan changed the title [PRD-525] Rely on PouchDB for search [PRD-525] [PRD-956] Rely on PouchDB for search Oct 21, 2024
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
count: Object.keys(searchIndex.index.store).length
}))
state.indexLength = Object.keys(searchEngine.searchIndexes).map(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: here you can use Object.entries().map(([key, value]) => {...} instead of Object.keys

    state.indexLength = Object.entries(searchEngine.searchIndexes).map(
      ([key, value]) => ({
        doctype: key,
        count: Object.keys(value.index.store).length
      })

Copy link
Contributor Author

@paultranvan paultranvan Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, I made the change in 811b02c

@paultranvan paultranvan merged commit 0266111 into main Oct 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants