Este conteúdo não está disponível no idioma selecionado.
3.3. Sharing indexes (two entities into the same directory)
Note
This is only presented here so that you know the option is available. There is really not much benefit in sharing indexes.
It is technically possible to store the information of more than one entity into a single Lucene index. There are two ways to accomplish this:
- Configuring the underlying directory providers to point to the same physical index directory. In practice, you set the property
hibernate.search.[fully qualified entity name].indexNameto the same value. As an example let’s use the same index (directory) for theFurnitureandAnimalentity. We just setindexNamefor both entities to for example “Animal”. Both entities will then be stored in the Animal directoryhibernate.search.org.hibernate.search.test.shards.Furniture.indexName = Aninal hibernate.search.org.hibernate.search.test.shards.Animal.indexName = Aninal
hibernate.search.org.hibernate.search.test.shards.Furniture.indexName = Aninal hibernate.search.org.hibernate.search.test.shards.Animal.indexName = AninalCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Setting the
@Indexedannotation’sindexattribute of the entities you want to merge to the same value. If we again wanted allFurnitureinstances to be indexed in theAnimalindex along with all instances ofAnimalwe would specify@Indexed(index=”Animal”)on bothAnimalandFurnitureclasses.