我试图运行Solr的搜索,我需要排序字段如的组合,支持Solr中FunctionQuery三元操作
q=*:*&sort=endtime != null ? endtime : starttime - 100;
据我可以从Solr的文档告诉(http://wiki.apache.org/solr/FunctionQuery )这不被支持。有没有另外一种方法来实现这一点?
我试图运行Solr的搜索,我需要排序字段如的组合,支持Solr中FunctionQuery三元操作
q=*:*&sort=endtime != null ? endtime : starttime - 100;
据我可以从Solr的文档告诉(http://wiki.apache.org/solr/FunctionQuery )这不被支持。有没有另外一种方法来实现这一点?
您需要在endtime
的架构中使用sortMissingLast
。
从http://lucene.472066.n3.nabble.com/about-sortMissingLast-and-sortMissingFirst-td473881.html - if sortMissingLast=true then it doesn't matter whether you sort "asc" or "desc", documents that don't have a value for that field will always come last. if sortMissingLast="false" then the default Lucene sort behavior is used, in which "missing" values are sorted the same as empty strings -- it is the "lowest" possible value, so they come first in asc sorts.
一旦你的,你都可以发出此查询: q=*:*&sort=endtime desc,starttime desc
(我不知道为什么你需要从starttime
减去100,因为排序顺序将是相同)。