-->
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.  [ 3 posts ] 
Author Message
 Post subject: Fuzzy Query Score
PostPosted: Tue Feb 26, 2013 5:38 am 
Newbie

Joined: Tue Feb 26, 2013 5:24 am
Posts: 2
Hi,
I have a problem about Fuzzy Query scoring.

Here is my entity.

Code:

@Indexed
public class PersonInfo {

    ...
    ...
    ...

    @Field
    @Boost(2.0f)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Field
    @Boost(2.0f)
    public String getLastnameTitle() {
        return lastnameTitle;
    }

    public void setLastnameTitle(String lastnameTitle) {
        this.lastnameTitle = lastnameTitle;
    }

    @Field
    @Boost(1.0f)
    public String getFatherName() {
        return fatherName;
    }

    public void setFatherName(String fatherName) {
        this.fatherName = fatherName;
    }

    @Field
    @Boost(1.0f)
    public String getMotherName() {
        return motherName;
    }

    public void setMotherName(String motherName) {
        this.motherName = motherName;
    }

    @Field
    @Boost(0.5f)
    public String getBirthPlace() {
        return birthPlace;
    }

    public void setBirthPlace(String birthPlace) {
        this.birthPlace = birthPlace;
    }

    @Field
    @Boost(0.5f)
    @DateBridge(resolution = Resolution.DAY)
    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

}


When I search for "John" as name that is exactly matched to indexed entity named "John", I get score as "0.61".
I expeced that score must be "1.00" because they are exactly same.
When I debug search code, in "FuzzyTermEnum" similarity is calculated as "1.00" that is what I expected. But score is calculated as "0.61".

Why score is calculated as "0.61".
Any suggestions?
or
How can I override scoring behaviour?


Top
 Profile  
 
 Post subject: Re: Fuzzy Query Score
PostPosted: Tue Feb 26, 2013 8:48 am 
Newbie

Joined: Tue Feb 26, 2013 5:24 am
Posts: 2
I override scoring behaviour simply

Code:
   public class CustomSimilarity extends Similarity {

      @Override
      public float computeNorm(String field, FieldInvertState state) {
         return state.getBoost();
      }

      @Override
      public float queryNorm(float sumOfSquaredWeights) {
         return 1;
      }

      @Override
      public float sloppyFreq(int distance) {
         return 1;
      }

      @Override
      public float tf(float freq) {
         return 1;
      }

      @Override
      public float idf(int docFreq, int numDocs) {
         return 1;
      }

      @Override
      public float coord(int overlap, int maxOverlap) {
         return 1;
      }
      
   }


Code:
   @Similarity(impl = CustomSimilarity.class)
   public class PersonInfo {
   
      ...
      ...
      ...
   }


Now it returns score what I expected.


Top
 Profile  
 
 Post subject: Re: Fuzzy Query Score
PostPosted: Wed Feb 27, 2013 12:06 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, your solution is correct, iff you want it to return a score of 1.

That's not what users need usually: the score is normalized across all documents in the index, so some terms have a higher scoring value as they are very peculiar; very frequent terms are less interesting to the search engine.

Make sure you test the general accuracy on larger data sets, overriding the Similarity might make it harder for people to search what they are looking for.

You can find an accurate explanation of scoring and similarity calculations on the book, chapter 12 of Hibernate Search in Action.

_________________
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.  [ 3 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.