Skip to content

Commit

Permalink
HSEARCH-1792 Polish warning about support of multi-tenancy in Hiberna…
Browse files Browse the repository at this point in the history
…te Search
  • Loading branch information
Sanne committed Feb 6, 2015
1 parent 6dd0585 commit 0ea6742
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions documentation/src/main/asciidoc/architecture.asciidoc
Expand Up @@ -165,16 +165,15 @@ org.hibernate.search.reader.ReaderProvider. The implementation must be thread sa

==== What is multi-tenancy?

The term multi-tenancy in general is applied to software development to indicate anarchitecture in
The term multi-tenancy in general is applied to software development to indicate an architecture in
which a single running instance of an application simultaneously serves multiple clients (tenants).
This is highly common in SaaS solutions.
Isolating information (data, customizations, etc) pertaining to the various tenants is a particular
challenge in these systems.
This includes the data owned by each tenant stored in the database.
You will find more details on how to enable multi-tenancy in the
You will find more details on how to enable multi-tenancy with Hibernate in the
link:$$http://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html/ch16.html$$[Hibernate ORM developer's guide].

You can create a full-text search session in the following way:
You can create a tenant-aware `FullTextSession` in the following way:

.Create a FullTextSession with a tenant identifier
====
Expand All @@ -185,20 +184,24 @@ FullTextSession fullTextSession = Search.getFullTextSession(session);
----
====

The FullTextSession will be bound to the specific tenant ("client-A" in the example)
The `FullTextSession` will be bound to the specific tenant ("client-A" in the example)
and the mass indexer will only index the entities associated to that tenant identifier.

==== Limitations

Integration of full automatic support for multi-tenancy has not been implemented yet.
You will need to take some limitations into account:
[WARNING]
====
Integration of fully automatic integration of Hibernate Search with the multi-tenancy features
of Hibernate ORM has not been implemented yet.
It is possible to experiment with it, and workaround most practical limitations, provided you
take the following limitations into account.
====

1. Queries won't be filtered automatically per tenant.
Hibernate Search will run the query on all the entries in the index.
If you need to filter per tenant you need to store the tenant identifier for each
document and filter on it.
document and filter on the keyword.

2. The purge operation won't consider the tenant,
it will delete all the documents in the index of the specific type,
ignoring the tenant identifier in the session.
2. The purgeAll operation will ignore the set tenant, and apply the purge globally.
It will delete all the documents in the index of the specific type, of any tenant.

0 comments on commit 0ea6742

Please sign in to comment.