1 31 32 package org.opencms.search; 33 34 import org.opencms.search.documents.I_CmsDocumentFactory; 35 36 import org.apache.lucene.search.DefaultSimilarity; 37 38 56 public class CmsSearchSimilarity extends DefaultSimilarity { 57 58 59 private static final double LOG10 = Math.log(10.0); 60 61 62 private static final long serialVersionUID = 3598754228215079733L; 63 64 67 public CmsSearchSimilarity() { 68 69 super(); 70 } 71 72 79 public float lengthNorm(String fieldName, int numTerms) { 80 81 if (fieldName.equals(I_CmsDocumentFactory.DOC_CONTENT)) { 82 return (float)(3.0 / (Math.log(1000 + numTerms) / LOG10)); 84 } 85 return (float)(1.0 / Math.sqrt(numTerms)); 87 } 88 } | Popular Tags |