How to index list of strings in Hibernate search?
i tried like this
@Field(index = Index.YES, analyze = Analyze.NO, store = Store.YES, analyzer = @Analyzer(definition = "customanalyzer_query"))
@ElementCollection(fetch = FetchType.EAGER)
private Set<String> hashedTagList;
I'm getting error while committing new object.
I'm using Hibernate ogm with mongodb
You can index element collections by using @IndexedEmbedded. This would be the easiest way to do what you want:
@Field(analyze = Analyze.NO, store = Store.YES)
@IndexedEmbedded
private Set<String> keywords = new HashSet<String>();
Note that you have to use Set so that the type of the contained element is clearly defined.
It's a workaround, we plan to fix the issue in a cleaner way in the upcoming Search 6.
You can also use a @FieldBridge to denormalize the data. The remark about using Set stays valid.
You can find the @FieldBridge we used at my previous job exactly for this purpose here: https://github.com/openwide-java/owsi-core-parent/blob/master/owsi-core/owsi-core-components/owsi-core-component-jpa/src/main/java/fr/openwide/core/jpa/search/bridge/StringCollectionFieldBridge.java .
By the way, you define an analyzer but you set analyze to Analyze.NO so your analyzer won't be used.