问题
I was wondering if it is possible to set the _type
field on the Elasticsearch document using an annotation on the entity class. I am currently using hibernate-search-orm
and hibernate-elasticsearch
version 5.8.2.Final
.
Adding the @Indexed(name="my-index-name")
annotation allows me to target a specific index. However, the document type is always the Class name. If the project is ever organized in a different way the type would not match the class.
回答1:
There's no way to do what you want at the moment.
If you change the organization of your project (e.g. moving packages around or changing a class name), you will have to reindex your data.
Using the class name is a good way to be sure we won't have conflicts in the names.
I will add it to the things we have to discuss for Search 6 and see if we want to act on this.
来源:https://stackoverflow.com/questions/47107499/override-elasticsearch-type-in-hibernate-search