diff --git a/mica-search/src/main/java/org/obiba/mica/search/queries/rql/RQLQueryWrapper.java b/mica-search/src/main/java/org/obiba/mica/search/queries/rql/RQLQueryWrapper.java index 9db56e9d32..aaf05a32b7 100644 --- a/mica-search/src/main/java/org/obiba/mica/search/queries/rql/RQLQueryWrapper.java +++ b/mica-search/src/main/java/org/obiba/mica/search/queries/rql/RQLQueryWrapper.java @@ -502,7 +502,10 @@ public List visit(ASTNode node) { List sortBuilders = Lists.newArrayList(); if (node.getArgumentsSize() >= 1) { for(int i = 0; i < node.getArgumentsSize(); i++) { - sortBuilders.add(processArgument(node.getArgument(i).toString())); + SortBuilder sortBuilder = processArgument(node.getArgument(i).toString()); + ((FieldSortBuilder) sortBuilder).unmappedType("string"); + sortBuilder.missing("_last"); + sortBuilders.add(sortBuilder); } } return sortBuilders; diff --git a/mica-search/src/test/java/org/obiba/mica/search/queries/rql/RQLQueryWrapperTest.java b/mica-search/src/test/java/org/obiba/mica/search/queries/rql/RQLQueryWrapperTest.java index 7b3f8678a9..f47c58d774 100644 --- a/mica-search/src/test/java/org/obiba/mica/search/queries/rql/RQLQueryWrapperTest.java +++ b/mica-search/src/test/java/org/obiba/mica/search/queries/rql/RQLQueryWrapperTest.java @@ -343,7 +343,9 @@ public void test_rql_query_term_and_limit_and_sort() throws IOException { assertThat(rqlQueryWrapper.getSize()).isEqualTo(4); String expectedSort = "\n" + "\"name\"{\n" + - " \"order\" : \"desc\"\n" + + " \"order\" : \"desc\",\n" + + " \"missing\" : \"_last\",\n" + + " \"unmapped_type\" : \"string\"\n" + "}"; assertThat(rqlQueryWrapper.getSortBuilders().get(0).toString()).isEqualTo(expectedSort); }