Skip to content

Commit

Permalink
TRUNK-4424 Added missing class
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Jul 15, 2014
1 parent 4b24bd0 commit ba5d463
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.api.db.hibernate.search;

import org.apache.lucene.index.FieldInvertState;
import org.apache.lucene.search.DefaultSimilarity;

public class ConceptNameSimilarity extends DefaultSimilarity {

private static final long serialVersionUID = 1L;

@Override
public float computeNorm(String field, FieldInvertState state) {
final int numTerms;
if (discountOverlaps)
numTerms = state.getLength() - state.getNumOverlap();
else
numTerms = state.getLength();

//Score longer documents much lower
return state.getBoost() * ((float) (1.0 / numTerms / numTerms / numTerms / numTerms));
}
}

0 comments on commit ba5d463

Please sign in to comment.