java - Lucene - Return results ordered by the number of matching fields -
i have lucene index numerous fields. i'd utilize find documents ranked number of fields matched , have results indicate how many fields matched.
in particular example, documents in lucene index represent web pages , fields things title, meta description, h1 text, etc.
if search term "bicycle", want documents contain word "bicycle" in field returned. however, i'd relevancy score indicate number of fields contain keyword "bicycle". example, if document contains "bicycle" in title , meta description, i'd document rank higher 1 contains "bicycle" in title. i'd able determine first document contains 2 matches sec document contains 1 match. frequency of keyword in particular field not matter. care know whether or not matched.
i know can utilize booleanquery
find matches on single field , can combine these , or or on multiple fields i'm not sure how perform query homecoming document matches on field homecoming indicator of how many fields matched.
any help much appreciated!
in lucene, searching on field can done forming queries title:a web page
. suppose create queries q1, q2, .. qn above n fields. searching using these queries homecoming document ids store in lists l1, l2,.. ln. now, merge them in set s. each item in s, check how many lists (or lists) item belong to. should solve problem, if understood right.
java lucene
No comments:
Post a Comment