doushi3202
doushi3202
2015-02-12 07:07
浏览 19
已采纳

Solr按结果排序[关闭]

I have indexed a table which is giving me result like following

A
B
C
D
E
F
H
H
A
B

I want to sort result in such a manner that I get H first everytime and then rest should be sort by asc like

H
H
A
A
B
B
C
D
so on...

I am not finding a way for this. Please help.

图片转代码服务由CSDN问答提供 功能建议

我已经索引了一个表,它给我的结果如下

 < 代码> A 
B 
C 
D 
E 
F 
H 
H 
A 
B 
   
 
 

我想以这样的方式对结果进行排序 H首先每次,然后休息应按asc排序

  H 
H 
A 
A 
B 
B 
C 
D 
so on ... 
 <  / code>  
 
 

我找不到办法。 请帮忙。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongzhuo1880
    dongzhuo1880 2015-02-12 09:16
    已采纳

    This depends on the search query you are using in order to get the results. You could modify your query parameter so that it matches the exact result you want to be on the top, and pass the original query in q.alt parameter, and then apply the sorting you wish to use.

    Note that in order to use q.alt, you need to use dismax or edismax query parser.

    点赞 评论
  • dscpg80066
    dscpg80066 2015-02-12 07:21
    $alpha = array("A","B","C","D","E","F","H","H","A","B");
    
    $first = array("H");
    $alpha =array_diff($alpha, $first);
    asort($alpha);
    $alpha= $first + $alpha;
    

    Demo

    点赞 评论

相关推荐