Hi!
We are upgrading a system from java 1.6 to java 1.8 and also upgrading Hibernate Search from version 4.5.3.Final to 5.5.1.Final.
After upgrade, Hibernate Search won't index certain entities.
We have an entity Utbildning with an indexed list Utbildningstillfalle. Utbildningstillfalle has an indexed entity, Adress. This entity has spatial annotations.
The problem we have is that if the list of Utbildningstillfalle in Utbildning contains more than one object, Utbildning won¨t be indexed.
We get the following error code :
ERROR 2016-04-15 15:57:22,589 org.hibernate.search.exception.impl.LogErrorHandler - HSEARCH000058: HSEARCH000183: Unable to index instance of type Utbildning while batch indexing: Utbildning{namn='utbNamn', forkunskaper='forkunskaper', beskrivning='cccc dddd aaaa anna-lisa', nyckelord='null', startDatum=2011-03-02, slutDatum=2019-03-02, externtSokbar=true, internInformation='intern info', utbildningId=1}
java.lang.IllegalArgumentException: DocValuesField "utbildningstillfalleLista.adress.location_HSSI_Latitude" appears more than once in this document (only one value is allowed per field)
at org.apache.lucene.index.NumericDocValuesWriter.addValue(NumericDocValuesWriter.java:54)
at org.apache.lucene.index.DefaultIndexingChain.indexDocValue(DefaultIndexingChain.java:421)
at org.apache.lucene.index.DefaultIndexingChain.processField(DefaultIndexingChain.java:376)
at org.apache.lucene.index.DefaultIndexingChain.processDocument(DefaultIndexingChain.java:300)
at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:234)
at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:450)
at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1475)
at org.hibernate.search.backend.impl.lucene.IndexWriterDelegate.updateDocument(IndexWriterDelegate.java:74)
at org.hibernate.search.backend.impl.lucene.IndexWriterDelegate.addDocument(IndexWriterDelegate.java:53)
at org.hibernate.search.backend.impl.lucene.works.AddWorkExecutor.performWork(AddWorkExecutor.java:54)
at org.hibernate.search.backend.impl.lucene.LuceneBackendTaskStreamer.doWork(LuceneBackendTaskStreamer.java:52)
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessor.applyStreamWork(LuceneBackendQueueProcessor.java:76)
at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.performStreamOperation(DirectoryBasedIndexManager.java:125)
at org.hibernate.search.backend.impl.StreamingOperationExecutorSelector$AddSelectionExecutor.performStreamOperation(StreamingOperationExecutorSelector.java:106)
at org.hibernate.search.backend.impl.batch.DefaultBatchBackend.sendWorkToShards(DefaultBatchBackend.java:62)
at org.hibernate.search.backend.impl.batch.DefaultBatchBackend.enqueueAsyncWork(DefaultBatchBackend.java:48)
at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.index(IdentifierConsumerDocumentProducer.java:292)
at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.indexAllQueue(IdentifierConsumerDocumentProducer.java:223)
at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.loadList(IdentifierConsumerDocumentProducer.java:177)
at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.loadAllFromQueue(IdentifierConsumerDocumentProducer.java:140)
at org.hibernate.search.batchindexing.impl.IdentifierConsumerDocumentProducer.run(IdentifierConsumerDocumentProducer.java:117)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Has anyone encountered this problem before? Sollutions?
If I remove the spatial annotations in Adress and index the fields as an ordinary Double, there are no problems so it has to do with spatial annotations.
Here are som code snippets:
Code:
@Entity
@FullTextFilterDefs({
@FullTextFilterDef(name = "utbildningInternSokningFilterFactory", impl = UtbildningInternSokningFilterFactory.class, cache = FilterCacheModeType.NONE),
@FullTextFilterDef(name = "utbildningExternSokningFilterFactory", impl = UtbildningExternSokningFilterFactory.class, cache = FilterCacheModeType.NONE),
@FullTextFilterDef(name = "utbildningUtanTillfallenInternSokningFilterFactory", impl = UtbildningUtanTillfallenInternSokningFilterFactory.class, cache = FilterCacheModeType.NONE)
})
@AnalyzerDef(name = "commaalyzer",
charFilters = {@CharFilterDef(factory = HTMLStripCharFilterFactory.class)},
tokenizer = @TokenizerDef(factory = PatternTokenizerFactory.class,
params = {
@org.hibernate.search.annotations.Parameter(name = "pattern", value = ",")
}),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class)
})
@DynamicUpdate(value = true)
@Table(name = "UTBILDNING")
@Indexed(interceptor = IndexWhenStatusActiveInterceptor.class)
public class Utbildning {
@DocumentId
@Id
@Column(name = "UTBILDNING_ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "UTBILDNING_SEQ_GEN")
@SequenceGenerator(name = "UTBILDNING_SEQ_GEN", sequenceName = "SEQ_UTBILDNING", allocationSize = 1)
private Long utbildningId;
@IndexedEmbedded(depth = 4, includeEmbeddedObjectId = true)
@OneToMany(mappedBy = "utbildning", fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
private Set<DUtbildningstillfalle> utbildningstillfalleLista = new HashSet<DUtbildningstillfalle>();
public Utbildning() {
}
public Long getUtbildningId() {
return utbildningId;
}
public void setUtbildningId(Long utbildningId) {
this.utbildningId = utbildningId;
}
public Set<Utbildningstillfalle> getUtbildningstillfalleLista() {
return utbildningstillfalleLista;
}
public void setUtbildningstillfalleLista(
Set<Utbildningstillfalle> utbildningstillfalleLista) {
this.utbildningstillfalleLista = utbildningstillfalleLista;
}
/* Removed irrelevant fields and equals/hashcode methods */
}
Code:
@Entity
@FullTextFilterDefs({
@FullTextFilterDef(name = "utbildningstillfalleExternSokningFilterFactory", impl = UtbildningstillfalleExternSokningFilterFactory.class),
@FullTextFilterDef(name = "utbildningstillfalleInternSokningFilterFactory", impl = UtbildningstillfalleInternSokningFilterFactory.class)
})
@DynamicUpdate(value = true)
@Table(name = "UTBILDNINGSTILLFALLE")
@NamedQueries({@NamedQuery(name = DUtbildningstillfalle.NQ_HAMTA_ALLA, query = "SELECT u FROM DUtbildningstillfalle u")})
@Indexed(interceptor = IndexWhenStatusActiveInterceptor.class)
public class Utbildningstillfalle {
@DocumentId
@Id
@Column(name = "UTBILDNINGSTILLFALLE_ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "UTBILDNINGSTILLFALLE_SEQ_GEN")
@SequenceGenerator(name = "UTBILDNINGSTILLFALLE_SEQ_GEN", sequenceName = "SEQ_UTBILDNINGSTILLFALLE", allocationSize = 1)
private Long utbildningstillfalleId;
@ContainedIn
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE, optional = false)
@JoinColumn(name = "UTBILDNING_ID", referencedColumnName = "UTBILDNING_ID", nullable = false)
private Utbildning utbildning;
@IndexedEmbedded(includeEmbeddedObjectId = true)
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE, optional = false)
@JoinColumn(name = "ADRESS_ID", referencedColumnName = "ADRESS_ID", nullable = false)
private Adress adress;
public void setUtbildning(Utbildning utbildning) {
this.utbildning = utbildning;
}
public Utbildning getUtbildning() {
return utbildning;
}
public Adress getAdress() {
return adress;
}
public void setAdress(Adress adress) {
this.adress = adress;
}
/* Removed irrelevant fields and equals/hashcode methods */
}
Code:
@Spatial(name = "location", spatialMode = SpatialMode.RANGE)
@Indexed(interceptor = IndexWhenStatusActiveInterceptor.class)
@Entity
@DynamicUpdate(value = true)
@Table(name = "ADRESS")
public class Adress {
@DocumentId
@Id
@Column(name = "ADRESS_ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ADRESS_SEQ_GEN")
@SequenceGenerator(name = "ADRESS_SEQ_GEN", sequenceName = "SEQ_ADRESS", allocationSize = 1)
private Long adressId;
@Latitude(of = "location")
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES, indexNullAs = "-1")
@Column(name = "LATITUDE")
private Double latitud;
@Longitude(of = "location")
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES, indexNullAs = "-1")
@Column(name = "LONGITUDE")
private Double longitud;
public Adress() {
}
public Long getAdressId() {
return adressId;
}
public void setAdressId(Long adressId) {
this.adressId = adressId;
}
public Double getLatitud() {
return latitud;
}
public void setLatitud(Double latitud) {
this.latitud = latitud;
}
public Double getLongitud() {
return longitud;
}
public void setLongitud(Double longitud) {
this.longitud = longitud;
}
/* Removed irrelevant fields and equals/hashcode methods */
}