}
public void testSorting() throws IOException
{
SolrCore core = h.getCore();
assertU(adoc("id", "a", "title", "ipod", "str_s", "a" ));
assertU(adoc("id", "b", "title", "ipod ipod", "str_s", "b" ));
assertU(adoc("id", "c", "title", "ipod ipod ipod", "str_s", "c" ));
assertU(adoc("id", "x", "title", "boosted", "str_s", "x" ));
assertU(adoc("id", "y", "title", "boosted boosted", "str_s", "y" ));
assertU(adoc("id", "z", "title", "boosted boosted boosted", "str_s", "z" ));
assertU(commit());
String query = "title:ipod";
Map<String,String> args = new HashMap<String, String>();
args.put( CommonParams.Q, query );
args.put( CommonParams.QT, "/elevate" );
args.put( CommonParams.FL, "id,score" );
args.put( "indent", "true" );
//args.put( CommonParams.FL, "id,title,score" );
SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("Make sure standard sort works as expected", req
,"//*[@numFound='3']"
,"//result/doc[1]/str[@name='id'][.='a']"
,"//result/doc[2]/str[@name='id'][.='b']"
,"//result/doc[3]/str[@name='id'][.='c']"
);
// Explicitly set what gets boosted
IndexReader reader = core.getSearcher().get().getReader();
QueryElevationComponent booster = (QueryElevationComponent)core.getSearchComponent( "elevate" );
booster.elevationCache.clear();
booster.setTopQueryResults( reader, query, new String[] { "x", "y", "z" }, null );
assertQ("All six should make it", req
,"//*[@numFound='6']"