-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid deprecation warning when running the ML datafeed extractor. #31463
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import org.elasticsearch.script.Script; | ||
import org.elasticsearch.search.SearchHit; | ||
import org.elasticsearch.search.fetch.StoredFieldsContext; | ||
import org.elasticsearch.search.fetch.subphase.DocValueFieldsContext; | ||
import org.elasticsearch.search.sort.SortOrder; | ||
import org.elasticsearch.xpack.core.ClientHelper; | ||
import org.elasticsearch.xpack.core.ml.datafeed.extractor.DataExtractor; | ||
|
@@ -47,6 +48,7 @@ class ScrollDataExtractor implements DataExtractor { | |
|
||
private static final Logger LOGGER = Loggers.getLogger(ScrollDataExtractor.class); | ||
private static final TimeValue SCROLL_TIMEOUT = new TimeValue(30, TimeUnit.MINUTES); | ||
private static final String EPOCH_MILLIS_FORMAT = "epoch_millis"; | ||
|
||
private final Client client; | ||
private final ScrollDataExtractorContext context; | ||
|
@@ -115,7 +117,11 @@ private SearchRequestBuilder buildSearchRequest(long start) { | |
context.query, context.extractedFields.timeField(), start, context.end)); | ||
|
||
for (String docValueField : context.extractedFields.getDocValueFields()) { | ||
searchRequestBuilder.addDocValueField(docValueField); | ||
if (docValueField.equals(context.extractedFields.timeField())) { | ||
searchRequestBuilder.addDocValueField(docValueField, EPOCH_MILLIS_FORMAT); | ||
} else { | ||
searchRequestBuilder.addDocValueField(docValueField, DocValueFieldsContext.USE_DEFAULT_FORMAT); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the default format for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On 6.x, the default is to keep returning a date time object for backward compatibility. If you use In 7.x I plan to make |
||
} | ||
} | ||
String[] sourceFields = context.extractedFields.getSourceFields(); | ||
if (sourceFields.length == 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the value going to be a
String
rather than along
here since we're explicitly setting the format toepoch_millis
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct.