Set boost on fields using Lucene -
i implementing word search using lucene. want ad 2 fields each document: title field, contains first 100 characters document , contents field, contains rest of characters document.
contenthandler handler = new bodycontenthandler(); try { parser.parse(is, handler, metadata); } { is.close(); } document doc = new document(); field titlefield = new field("title", handler.tostring().substring(0, 100), field.store.yes, field.index.analyzed_no_norms); field contentsfield = new field("contents", handler.tostring().substring(101), field.store.yes, field.index.analyzed_no_norms);
i want add boosting each field: want title count 70% , content count 30%.
i doing this:
titlefield.setboost(1.70f); doc.add(titlefield); doc.add(contentsfield); doc.add(new field("filename", metadata.get(metadata.resource_name_key), field.store.yes, field.index.analyzed));
however, cannot see diferrence documents procentually.
does length of field matter in calculationg scorting?
i have try implement class extends defaultsimilarity, not help.
class isolationsimilarity extends defaultsimilarity { public isolationsimilarity(){ } @override public float idf(int docfreq, int numdocs) { return(float)1.0; } @override public float coord(int overlap, int maxoverlap) { return 1.0f; } @override public float lengthnorm(string fieldname, int numtokens){ return 1.0f; } }
have tried increasing amount boost field? keep in mind the method used of encoding value extremely lossy, in order save space in index. can count on 1 significant digit of precision.
try larger value, , pull until have tuned way want.
that said, should see small difference between two. based on testing, 1.7 similarity end value of 1.5, when lengthnorm has been stubbed.
have run explain()
, see influencing query? because you've boost title, doesn't mean match on title first result returned.
Comments
Post a Comment