I am using @Indexed on a few of my entities. My question is the following:
Can I prevent hibernate search / lucene from indexing the id field? Normally that is a good idea, but in this case, it does not make much sense, because it is an UUID…
I hope, that you can help me, did not found any solution so far…
If you’re using Elasticsearch and what’s bothering you is the id property that Hibernate Search adds automatically to every document, I’m afraid you cannot solve that in Hibernate Search 5. On the bright side, Hibernate Search 6 no longer does that anymore, so you might want to upgrade.
If there is another reason, please explain so that I can help.
It fills up my index with stuff I do not need (and did not do that in the past versions of hibernate, but I do not know the versions exactly).
This does not work as well, because the only things, I want to have in my index, need special analyzers to work (and @DocumentId can not have an @Field annotation as well).
I am using lucene, here is a section of my class annotations (I am using different analyzers for indexing and searching):
So if you need to update/delete documents, or if you need to retrieve the entity corresponding to a document, then you need to index the document identifier. This is not “stuff you do not need”.
Without an indexed document identifier, it’s simply not possible to update/delete documents.
Hibernate Search has been indexing document identifiers for as long as I can remember. I you feel there’s been a change, please give more details about the state of the index in previous versions, and the state of the index in recent versions (field names, content, …).
I have to thank you!
Well, I then keep the ID for you, although I o not use them in my queries myself, but that is ok. Would have been nice, if I could have removed it from my index, but well, then not.