Skip to content

Commit

Permalink
SOLR-2949: Fix + improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markrmiller committed Mar 17, 2012
1 parent d73db1c commit 7c88528
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Expand Up @@ -399,7 +399,7 @@ public void prepare(ResponseBuilder rb) throws IOException {
SortSpec sortSpec = rb.getSortSpec();
if (sortSpec.getSort() == null) {
sortSpec.setSort(new Sort(new SortField[]{
new SortField("_elevate_", comparator, true),
new SortField(idField, comparator, true),
new SortField(null, SortField.Type.SCORE, false)
}));
} else {
Expand All @@ -409,12 +409,12 @@ public void prepare(ResponseBuilder rb) throws IOException {
ArrayList<SortField> sorts = new ArrayList<SortField>(current.length + 1);
// Perhaps force it to always sort by score
if (force && current[0].getType() != SortField.Type.SCORE) {
sorts.add(new SortField("_elevate_", comparator, true));
sorts.add(new SortField(idField, comparator, true));
modify = true;
}
for (SortField sf : current) {
if (sf.getType() == SortField.Type.SCORE) {
sorts.add(new SortField("_elevate_", comparator, sf.getReverse()));
sorts.add(new SortField(idField, comparator, !sf.getReverse()));
modify = true;
}
sorts.add(sf);
Expand Down
Expand Up @@ -51,16 +51,17 @@ public static void beforeClass() throws IOException {

@Override
public void doTest() throws Exception {


del("*:*");
indexr(id,"1", "text", "XXXX XXXX", "field_t", "anything");
indexr(id,"2", "text", "YYYY YYYY", "plow_t", "rake");
indexr(id,"3", "text", "ZZZZ ZZZZ");
indexr(id,"4", "text", "XXXX XXXX");
indexr(id,"5", "text", "ZZZZ ZZZZ ZZZZ");
indexr(id,"6", "text", "ZZZZ");
indexr(id,"1", "int_i", "1", "text", "XXXX XXXX", "field_t", "anything");
indexr(id,"2", "int_i", "2", "text", "YYYY YYYY", "plow_t", "rake");
indexr(id,"3", "int_i", "3", "text", "ZZZZ ZZZZ");
indexr(id,"4", "int_i", "4", "text", "XXXX XXXX");
indexr(id,"5", "int_i", "5", "text", "ZZZZ ZZZZ ZZZZ");
indexr(id,"6", "int_i", "6", "text", "ZZZZ");

index_specific(2, id, "7", "int_i", "7", "text", "solr");
commit();

handle.put("explain", SKIPVAL);
handle.put("debug", SKIPVAL);
handle.put("QTime", SKIPVAL);
Expand All @@ -74,15 +75,19 @@ public void doTest() throws Exception {
handle.put("q", SKIP);
handle.put("qt", SKIP);
query("q", "*:*", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", "sort", "id desc", CommonParams.FL, "id, score, [elevated]");

query("q", "ZZZZ", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "forceElevation", "true", "sort", "int_i desc");

query("q", "ZZZZ", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "id");
query("q", "solr", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "forceElevation", "true", "sort", "int_i asc");

query("q", "ZZZZ", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "score", "score desc");
// currently cannot sort by id with distrib
// query("q", "ZZZZ", "qt", "/elevate", "shards.qt", "/elevate", "rows", "500", CommonParams.FL, "*, [elevated]", "forceElevation", "true", "sort", "id desc");
}

protected void indexr(Object... fields) throws Exception {
SolrInputDocument doc = new SolrInputDocument();
addFields(doc, fields);
indexDoc(doc);
}

}

0 comments on commit 7c88528

Please sign in to comment.