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

configurable/smarter searchIndices #1609

Closed
1 of 2 tasks
sleidig opened this issue Dec 20, 2022 · 3 comments
Closed
1 of 2 tasks

configurable/smarter searchIndices #1609

sleidig opened this issue Dec 20, 2022 · 3 comments

Comments

@sleidig
Copy link
Member

sleidig commented Dec 20, 2022

search indices should usually be done on any of the toString attributes. Additionally we could introduce an static entity property searchIndices similar to the toStringAttributes, to make search indexing configurable. The heuristic of a "name" and "projectnumber" property for Child entity is not good enough for other use cases.

  • always index toString parts

  • allow a static entity type config searchIndices similar to toStringAttributes

  • implement a "recalculate all search indices" button in the AdminComponent to be able to update existing data for index changes (or should we create that index differently so that entities themselves don't have to be changed ...?)

  • rewrite the search index logic to generate a pouchdb query based on schemas dynamically instead of relying on a searchIndices function on the entity classes

@sleidig
Copy link
Member Author

sleidig commented Jan 26, 2023

After discussion the way to go here seems to be:

  • remove the searchIndices getter from Entity classes
  • add an optional field "searchable" to DatabaseField schema definitions to flag properties that should be indexed
  • rewrite the way the search index is created so that it dynamically creates a function that uses
    • any toStringAttributes properties
    • any additional property whose schema defines it as "searchable"
    • splits all values of these properties at whitespaces

private createSearchIndex(): Observable<void> {
// `emit(x)` to add x as a key to the index that can be searched
const searchMapFunction = `
(doc) => {
if (doc.hasOwnProperty("searchIndices")) {
doc.searchIndices.forEach(word => emit(word.toString().toLowerCase()));
}
}`;
const designDoc = {
_id: "_design/search_index",
views: {
by_name: {
map: searchMapFunction,
},
},
};
// TODO move this to a service so it is not executed whenever a user logs in
return from(this.indexingService.createIndex(designDoc));
}

@aam-digital-ci
Copy link
Collaborator

🎉 This issue has been resolved in version 3.19.0-master.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci
Copy link
Collaborator

🎉 This issue has been resolved in version 3.19.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants