mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-24 17:09:48 +00:00
ingest: Fix bug that prevent date_index_name processor from accepting timestamps specified as a json number
Closes #26890
This commit is contained in:
parent
6b53dadcf9
commit
bba70205e3
@ -25,6 +25,7 @@ import java.util.IllformedLocaleException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
@ -61,7 +62,8 @@ public final class DateIndexNameProcessor extends AbstractProcessor {
|
||||
|
||||
@Override
|
||||
public void execute(IngestDocument ingestDocument) throws Exception {
|
||||
String date = ingestDocument.getFieldValue(field, String.class);
|
||||
// Date can be specified as a string or long:
|
||||
String date = Objects.toString(ingestDocument.getFieldValue(field, Object.class));
|
||||
|
||||
DateTime dateTime = null;
|
||||
Exception lastException = null;
|
||||
|
@ -62,6 +62,11 @@ public class DateIndexNameProcessorTests extends ESTestCase {
|
||||
Collections.singletonMap("_field", "1000500"));
|
||||
dateProcessor.execute(document);
|
||||
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
|
||||
|
||||
document = new IngestDocument("_index", "_type", "_id", null, null,
|
||||
Collections.singletonMap("_field", 1000500L));
|
||||
dateProcessor.execute(document);
|
||||
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
|
||||
}
|
||||
|
||||
public void testUnix()throws Exception {
|
||||
|
Loading…
x
Reference in New Issue
Block a user