-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hibernate search 5.6 beta1 : wrong mapping
PostPosted: Sun Jul 17, 2016 2:02 pm 
Newbie

Joined: Sun Jul 17, 2016 1:29 pm
Posts: 2
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.


Top
 Profile  
 
 Post subject: Re: hibernate search 5.6 beta1 : wrong mapping
PostPosted: Fri Sep 09, 2016 6:22 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,

could you narrow down your example please. From what I see, it seems to have ignored Analyze=NO, is that the problem you are pointing out?

I just tested version 5.6.0.Beta2 and this seems to work fine, could you test this newer version?

Thanks!

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.