Skip to content

Commit

Permalink
add test case for build in search field
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis95 committed May 2, 2022
1 parent 1589c13 commit 71079a2
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public void titleSort() throws Exception {
search.addSort(new Sort("title").descending().missingLast());
searchResult = zuliaWorkPool.search(search);
Assertions.assertNull(searchResult.getFirstDocument().get("title"));


}

@Test
Expand Down Expand Up @@ -460,7 +462,7 @@ public void dateSort() throws Exception {

@Test
@Order(9)
public void scoreSort() throws Exception {
public void zuliaSort() throws Exception {
SearchResult searchResult;

Search search = new Search(INDEX_NAME).setAmount(10).addQuery(new ScoredQuery("title:special OR title:secret"));
Expand All @@ -479,6 +481,24 @@ public void scoreSort() throws Exception {
searchResult = zuliaWorkPool.search(search);

Assertions.assertEquals("40", searchResult.getFirstDocument().get("id"));


search = new Search(INDEX_NAME).setAmount(10);

search.clearSort();
search.addSort(new Sort(ZuliaConstants.ID_SORT_FIELD).ascending());
searchResult = zuliaWorkPool.search(search);
Assertions.assertEquals("0", searchResult.getFirstDocument().get("id"));
Assertions.assertEquals("0", searchResult.getFirstResult().getUniqueId());


search.clearSort();
search.addSort(new Sort(ZuliaConstants.ID_SORT_FIELD).descending());
searchResult = zuliaWorkPool.search(search);
//99 here instead of 199 because sorting as a string not a number
Assertions.assertEquals("99", searchResult.getFirstDocument().get("id"));
Assertions.assertEquals("99", searchResult.getFirstResult().getUniqueId());

}

@Test
Expand Down

0 comments on commit 71079a2

Please sign in to comment.