solrj - Solr - retrieve documents in the same order as the IDs provided in the query -
i'm using apache solr 4.7.2.
i need implement following behavior: user provides list of ids , solr returns documents paginated , ordered same order user informed ids.
i came across boost terms approach. if user provides ids "2875141 2873071 2875198 108142 2918841 2870688 107920 2870637 2870636 2870635 2918792 107721 2875078 2875166 2875151 2918829 2918808", solr query be:
studentid:(2875141^16 2873071^15 2875198^14 108142^13 2918841^12 2870688^11 107920^10 2870637^9 2870636^8 2870635^7 2918792^6 107721^5 2875078^4 2875166^3 2875151^2 2918829^2 2918808^1)
but approach not working. example specifically, can see @ explain query, highest score isn't ^16
.
if use big boost values such 1, 10, 100, 1000, 10000 , on, adding 1 0 @ end, suggested in cookbook, ordering works fine. issue if user searches 200 items instance, query long causing communication issues.
is there other approach achieve this? if not, use multiplication or exponencial operations in order big boost factors less characters?
thanks
a viable option write custom solr function takes in input name of field , boosts content position. instance:
bq=mycustomboostfunction(fieldname, boostfactor)
where boostfactor optional or omit in solution. boosting part of java code within function. kind of solution have pros , cons:
pros
the same function reused other fields without additional implementation;
the boost factor allow tune solution;
any calculation done within java code without affecting query length.
cons
- your function implementation slow if read content of field instead of using payloads.
Comments
Post a Comment