Hello,
i have started to use hibernate search 5.6 beta and plan to deploy it in production if everything is fine.
i am facing a issue. generated elasticsearch mapping doesnt take account field annotation.
for example here is one of my entity
Code:
@Entity
@Indexed(index = "spn-member")
@Table(name = "spn_member")
@Analyzer(definition = "french")
public class Member extends GenericEntity implements Serializable, IAuditable {
private static final long serialVersionUID = -1172312819406239711L;
@IndexedEmbedded(prefix = "company_", includeEmbeddedObjectId = true)
private Company company;
@Field(norms = Norms.NO, store = Store.NO)
private String email;
private String password;
@Field(analyze = Analyze.YES, store = Store.YES)
private String function;
@Fields({
@Field(analyze = Analyze.YES, store = Store.YES),
@Field(name = "lastName_forSort", analyze = Analyze.NO, store = Store.YES) })
@SortableField
@Boost(10.0f)
private String lastName;
@Fields({
@Field(analyze = Analyze.YES, store = Store.YES),
@Field(name = "firstName_forSort", analyze = Analyze.NO, store = Store.YES) })
@SortableField
@Boost(8.0f)
private String firstName;
@Field(norms = Norms.NO, store = Store.NO)
private String phoneNumber;
@Field(norms = Norms.NO, store = Store.NO)
private String mobileNumber;
@Field(norms = Norms.NO, store = Store.NO)
private String faxNumber;
private String photo;
private Date inscriptionDate;
@Field(norms = Norms.NO, store = Store.YES)
private boolean enabled;
@Field(norms = Norms.NO, store = Store.YES)
private boolean activated;
@IndexedEmbedded(prefix = "authorities_", depth = 1, includeEmbeddedObjectId = true)
private Set<Authority> authorities = new HashSet<Authority>();
@ElementCollection
private Set<MemberContact> contacts = new HashSet<MemberContact>();
private Set<ContactRequest> contactRequests = new HashSet<ContactRequest>();
@Field(norms = Norms.NO, store = Store.YES)
private boolean deleted;
@Field(norms = Norms.NO, store = Store.NO)
private boolean male;
private boolean completedProfil;
private boolean special;
private boolean acceptedCgu;
private boolean enlargeNetwork = true;
private boolean newsletter = true;
@Field(analyze = Analyze.YES, store = Store.NO)
private String presentation;
@Field(analyze = Analyze.YES, store = Store.NO)
private String realisation;
@Field(analyze = Analyze.YES, store = Store.NO)
private String mission;
private String facebookUrl;
private String twitterUrl;
private String viadeoUrl;
private String websiteUrl;
private String presentationVideo;
private String login;
private boolean registrationValidated;
private AddMemberEnum creationType;
and i get this mapping on elasticsearch side:
Code:
{
"spn-member" : {
"aliases" : { },
"mappings" : {
"com.smartpanda.spback.model.member.Member" : {
"properties" : {
"activated" : {
"type" : "boolean"
},
"authorities" : {
"properties" : {
"authorities_id" : {
"type" : "string"
},
"authorities_name" : {
"type" : "string"
}
}
},
"company" : {
"properties" : {
"areas" : {
"properties" : {
"company_areas_id" : {
"type" : "string"
},
"company_areas_timestamp" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
}
}
},
"company_activated" : {
"type" : "string"
},
"company_activityId" : {
"type" : "long"
},
"company_address" : {
"type" : "string"
},
"company_city" : {
"type" : "string"
},
"company_cityId" : {
"type" : "long"
},
"company_country" : {
"type" : "string"
},
"company_countryId" : {
"type" : "long"
},
"company_deleted" : {
"type" : "string"
},
"company_description" : {
"type" : "string"
},
"company_id" : {
"type" : "string"
},
"company_intranetId" : {
"type" : "string"
},
"company_leaderName" : {
"type" : "string"
},
"company_nafCode" : {
"type" : "string"
},
"company_nafLabel" : {
"type" : "string"
},
"company_name" : {
"type" : "string"
},
"company_registeredName" : {
"type" : "string"
},
"company_registeredName_forSort" : {
"type" : "string"
},
"company_siren" : {
"type" : "string"
},
"company_siret" : {
"type" : "string"
},
"company_state" : {
"type" : "string"
},
"company_stateCode" : {
"type" : "string"
},
"company_stateId" : {
"type" : "long"
},
"company_workforce" : {
"type" : "double"
},
"company_zipCode" : {
"type" : "string"
}
}
},
"deleted" : {
"type" : "boolean"
},
"email" : {
"type" : "string"
},
"enabled" : {
"type" : "boolean"
},
"faxNumber" : {
"type" : "string"
},
"firstName" : {
"type" : "string"
},
"firstName_forSort" : {
"type" : "string"
},
"function" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"lastName_forSort" : {
"type" : "string"
},
"male" : {
"type" : "boolean"
},
"mission" : {
"type" : "string"
},
"mobileNumber" : {
"type" : "string"
},
"phoneNumber" : {
"type" : "string"
},
"presentation" : {
"type" : "string"
},
"realisation" : {
"type" : "string"
},
"timestamp" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "1468711726735",
"uuid" : "BG07jMsWTyWQ3NdXiIdn0w",
"number_of_replicas" : "1",
"number_of_shards" : "5",
"version" : {
"created" : "2030499"
}
}
},
"warmers" : { }
}
}
Code:
<!-- Hibernate -->
<hibernate.version>5.1.0.Final</hibernate.version>
<hibernate-search.version>5.6.0.Beta1</hibernate-search.version>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-elasticsearch</artifactId>
<version>5.6.0.Beta1</version>
</dependency>
<!-- hibernate search -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>${hibernate-search.version}</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<groupId>org.hibernate.javax.persistence</groupId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- hibernate tools -->
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.3.GA</version>
</dependency>
all fields attributes from entity are just skipped. how can i solve this problem ?
i tried to define a good mapping by creating manually the index and the mapping. BUT hibernate searh override the actual mapping with his own.
because of this problem many of my termQuery are not working.
thanks in advance for you help.