Skip to content

Commit 7b00ab9

Browse files
committed
address searcher after
1 parent cd33aa0 commit 7b00ab9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

server/src/main/java/org/elasticsearch/search/searchafter/SearchAfterBuilder.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.lucene.search.SortedNumericSortField;
1515
import org.apache.lucene.search.SortedSetSortField;
1616
import org.apache.lucene.util.BytesRef;
17+
import org.elasticsearch.cluster.metadata.DataStream;
1718
import org.elasticsearch.common.ParsingException;
1819
import org.elasticsearch.common.Strings;
1920
import org.elasticsearch.common.io.stream.StreamInput;
@@ -190,7 +191,19 @@ private static Object convertValueFromSortType(String fieldName, SortField.Type
190191
} else {
191192
return format.parseBytesRef(value);
192193
}
193-
194+
case CUSTOM:
195+
// TODO: reconsider?
196+
if (DataStream.TIMESTAMP_FIELD_NAME.equals(fieldName)) {
197+
return format.parseLong(
198+
value.toString(),
199+
false,
200+
() -> { throw new IllegalStateException("now() is not allowed in [search_after] key"); }
201+
);
202+
} else {
203+
throw new IllegalArgumentException(
204+
"Comparator type [" + sortType.name() + "] for field [" + fieldName + "] is not supported."
205+
);
206+
}
194207
default:
195208
throw new IllegalArgumentException(
196209
"Comparator type [" + sortType.name() + "] for field [" + fieldName + "] is not supported."

0 commit comments

Comments
 (0)