I had this long-term problem, not quite understanding how to implement decent Lucene sorting or ranking. Say I have a list of cities and their populations. If someone is looking for “new” or “London”, I want a list of prefix matches sorted by population, and I have a prefix search job and sort by field that has a field to fill in, IE New Mexico, New York; or London, Londonderry.
However, I also always want the exact matching name to be at the top. Therefore, in the case of “London”, “London, London, Londonderry” should appear on the list, where the first London is in the UK and the second London is in Connecticut, even if Londonderry has more population than in London.
Does anyone have one solution for queries?
source share