-->
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.  [ 1 post ] 
Author Message
 Post subject: Scoring: Hibernate Search/Lucene experts wanted!
PostPosted: Fri Aug 29, 2008 4:35 am 
Newbie

Joined: Thu Sep 13, 2007 7:01 am
Posts: 11
Hi experts,

I have an urgent and very detailed question regarding Hibernate Search/Lucene. My question is about the scoring.. but let me first explain my domain-model:

There is a Person class having a one-to-many relationship to a Job class. This Job class has a many-to-many relationship to a Function class.

Here the code snippets

Person class
Code:
@Entity
@Name("person")
@Table(name = "person", schema = "public")
@Indexed
public class Person implements java.io.Serializable {

   ...

   @IndexedEmbedded(depth = 4)
   private Collection<Job> jobs = new ArrayList<Job>();
   
   @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE,
         CascadeType.REFRESH, CascadeType.REMOVE }, fetch = FetchType.LAZY, mappedBy = "person")
   public Collection<Job> getJobs() {
      return jobs;
   }

   ...
}


Job class:
Code:
@Entity
@Name("job")
@Table(name = "job", schema = "public")
@Indexed
public class Job implements java.io.Serializable {
   
   ...

   @ContainedIn
   private Person person;

   @IndexedEmbedded(depth = 2)
   private Collection<Function> functions = new ArrayList<Function>();

   @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE,
            CascadeType.REFRESH }, fetch = FetchType.LAZY)
      @JoinTable(name = "job_funktion", schema = "public", joinColumns = { @JoinColumn(name = "job_id") }, inverseJoinColumns = { @JoinColumn(name = "function_id") })
   public Collection<Function> getFunctions() {
      return this.functions;
   }
   
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "person_id")
   public Person getPerson() {
      return this.person;
   }
   
   ...
}


Function class:
Code:
@Entity
@Table(name = "funktion", schema = "public")
@Embeddable
@Indexed
public class Function implements java.io.Serializable {

   ...
   
   @FieldBridge(impl = LongBridge.class)
   private Long functioncode;
   
   private Collection<Job> jobs;
   
   @ManyToMany(fetch = FetchType.LAZY)
   @JoinTable(name = "job_function", schema = "public", joinColumns = { @JoinColumn(name = "function_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "job_id", nullable = false, updatable = false) })
   @ContainedIn
   public Collection<Job> getJobs() {
      return this.jobs;
   }
   
   @Column(name = "functioncode")
   public Long getFunctioncode() {
      return this.functioncode;
   }
   
   ...
}


I want to query and score persons regarding their jobs function-codes.
The important thing concerning the result scoring is that I do not care how often the search term is contained in the document. I also do not care how long the queried field is. All I want to know is if the search term (functioncode) is contained in the document or not. So I created my own Similarity class returning 1 for every factor in the similarity scoring formula (term-frequency, lengthNorm, etc), so I get the scores as expected.

For example I want to search all persons having jobs with functioncodes 510 or 520 or 530

My Lucene query is:

Code:
person.jobs.functions.functioncode:(510 520 530)^1.0


The returned result set of Hibernate Search is correct, but the scoring is not!
For example, persons having all 3 functioncodes get a higher score (100%) than persons with only one function code (50%).

What I want is that all persons get 100% even if they match only one of the 3 functioncodes. I though this should be solved by returning 1 for the tf- and lengthNorm method in my Similarty class....

I know that this question is really specific but maybe one of the Hibernate/Lucene experts can give me some hints. Any help would be appreciated.

Thanks,

Alexander


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

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.