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

Multiple enhancements to support more flexibility in configuration #75

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jguertin-gls
Copy link
Contributor

This change set address a few issues, which were implemented by us specifically to support the ability to have indexes that support multi-tenant databases. Specifically, we did the following:

  • When using "only" in the mapping, transient properties will now be allowed
  • "indexId" may now be added to mapping which will allow a change to which field is used as _id in the index.
  • Additionally, "indexId" will support multiple fields
  • Corrected a problem where counting the instances of a domain class sometimes occurred using the wrong hibernate session

This will allow properties such as transients to be index, when in the "only" clause
…This is done by adding a new indexId attribute to searchable that can be used to specify which fields to use as the index id.
…lock to ensure that the correct session is used to obtain the instance count
public SearchableClassMapping(GrailsDomainClass domainClass, Collection<SearchableClassPropertyMapping> propertiesMapping) {
this.domainClass = domainClass;
this.propertiesMapping = propertiesMapping;
this.identityProperties = [domainClass.identifier.name];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default, indentityProperties will behave as it did before, using the identifier as the sole property for indexId.

@jguertin-gls
Copy link
Contributor Author

This change will allow for an 'indexId' property to be added to the searchable closure. This value can either except a string, a list of properties or a map. The properties listed in 'indexId' will be concatenated together to form the _id value in the index, with a separator between them. The default separator will be ':', but this too may be overriden. Here are some examples of what it may look like, within searchable {}:

indexId = 'uniqueValue' // _id would contain the value of the 'uniqueValue' property
indexId = ['id', 'distinguisher'] // _id will be '<id>:<distinguisher>'
indexId properties: ['id', 'distinguisher'], separator: '-' // _id will be '<id>-<distinguisher>'

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.

1 participant