-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Using ObjectParser in UpdateRequest #29293
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
Changes from 5 commits
ce966d0
0d3fd89
a3a8087
d456759
2024751
fae7908
553bf99
28622b4
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 |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| --- | ||
| "Source filtering": | ||
| - skip: | ||
| version: " - 6.99.99" | ||
| reason: fields dropped in 7.0 | ||
|
|
||
| - do: | ||
| index: | ||
| refresh: true | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| --- | ||
| "Update result field": | ||
| - skip: | ||
| version: " - 6.99.99" | ||
| reason: fields dropped in 7.0 | ||
|
|
||
| - do: | ||
| update: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| --- | ||
| "Doc upsert": | ||
| - skip: | ||
| version: " - 6.99.99" | ||
| reason: fields dropped in 7.0 | ||
|
|
||
| - do: | ||
| update: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| --- | ||
| "Doc as upsert": | ||
| - skip: | ||
| version: " - 6.99.99" | ||
| reason: fields dropped in 7.0 | ||
|
|
||
| - do: | ||
| update: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| --- | ||
| "Routing": | ||
| - skip: | ||
| version: " - 6.99.99" | ||
| reason: fields dropped in 7.0 | ||
|
|
||
| - do: | ||
| indices.create: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| --- | ||
| "Parent with routing": | ||
| - skip: | ||
| version: " - 6.99.99" | ||
| reason: fields dropped in 7.0 | ||
|
|
||
| - do: | ||
| indices.create: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,8 +36,6 @@ | |
| import org.elasticsearch.common.bytes.BytesReference; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.logging.DeprecationLogger; | ||
| import org.elasticsearch.common.logging.Loggers; | ||
| import org.elasticsearch.common.lucene.uid.Versions; | ||
| import org.elasticsearch.common.unit.TimeValue; | ||
| import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; | ||
|
|
@@ -66,8 +64,6 @@ | |
| * @see org.elasticsearch.client.Client#bulk(BulkRequest) | ||
| */ | ||
| public class BulkRequest extends ActionRequest implements CompositeIndicesRequest, WriteRequest<BulkRequest> { | ||
| private static final DeprecationLogger DEPRECATION_LOGGER = | ||
| new DeprecationLogger(Loggers.getLogger(BulkRequest.class)); | ||
|
|
||
| private static final int REQUEST_OVERHEAD = 50; | ||
|
|
||
|
|
@@ -81,7 +77,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques | |
| private static final ParseField VERSION_TYPE = new ParseField("version_type"); | ||
| private static final ParseField RETRY_ON_CONFLICT = new ParseField("retry_on_conflict"); | ||
| private static final ParseField PIPELINE = new ParseField("pipeline"); | ||
| private static final ParseField FIELDS = new ParseField("fields"); | ||
| private static final ParseField SOURCE = new ParseField("_source"); | ||
|
|
||
| /** | ||
|
|
@@ -278,20 +273,21 @@ public BulkRequest add(byte[] data, int from, int length, @Nullable String defau | |
| */ | ||
| public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, | ||
| XContentType xContentType) throws IOException { | ||
| return add(data, defaultIndex, defaultType, null, null, null, null, null, true, xContentType); | ||
| return add(data, defaultIndex, defaultType, null, null, null, null, true, xContentType); | ||
| } | ||
|
|
||
| /** | ||
| * Adds a framed data in binary format | ||
| */ | ||
| public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex, | ||
| XContentType xContentType) throws IOException { | ||
| return add(data, defaultIndex, defaultType, null, null, null, null, null, allowExplicitIndex, xContentType); | ||
| return add(data, defaultIndex, defaultType, null, null, null, null, allowExplicitIndex, xContentType); | ||
| } | ||
|
|
||
| public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String | ||
| defaultRouting, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable String | ||
| defaultPipeline, @Nullable Object payload, boolean allowExplicitIndex, XContentType xContentType) throws IOException { | ||
| public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, | ||
| @Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, | ||
| @Nullable String defaultPipeline, @Nullable Object payload, boolean allowExplicitIndex, | ||
| XContentType xContentType) throws IOException { | ||
| XContent xContent = xContentType.xContent(); | ||
| int line = 0; | ||
| int from = 0; | ||
|
|
@@ -335,7 +331,6 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null | |
| String routing = defaultRouting; | ||
| String parent = null; | ||
| FetchSourceContext fetchSourceContext = defaultFetchSourceContext; | ||
| String[] fields = defaultFields; | ||
| String opType = null; | ||
| long version = Versions.MATCH_ANY; | ||
| VersionType versionType = VersionType.INTERNAL; | ||
|
|
@@ -375,21 +370,14 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null | |
| retryOnConflict = parser.intValue(); | ||
| } else if (PIPELINE.match(currentFieldName, parser.getDeprecationHandler())) { | ||
| pipeline = parser.text(); | ||
| } else if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) { | ||
| throw new IllegalArgumentException("Action/metadata line [" + line + "] contains a simple value for parameter [fields] while a list is expected"); | ||
| } else if (SOURCE.match(currentFieldName, parser.getDeprecationHandler())) { | ||
| fetchSourceContext = FetchSourceContext.fromXContent(parser); | ||
| } else { | ||
| throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter [" + currentFieldName + "]"); | ||
| } | ||
| } else if (token == XContentParser.Token.START_ARRAY) { | ||
| if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) { | ||
| DEPRECATION_LOGGER.deprecated("Deprecated field [fields] used, expected [_source] instead"); | ||
| List<Object> values = parser.list(); | ||
| fields = values.toArray(new String[values.size()]); | ||
| } else { | ||
|
Member
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. Removing the stuff under the
Author
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. Thanks! I put the |
||
| throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]"); | ||
| } | ||
| throw new IllegalArgumentException("Malformed action/metadata line [" + line + | ||
| "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]"); | ||
| } else if (token == XContentParser.Token.START_OBJECT && SOURCE.match(currentFieldName, parser.getDeprecationHandler())) { | ||
| fetchSourceContext = FetchSourceContext.fromXContent(parser); | ||
| } else if (token != XContentParser.Token.VALUE_NULL) { | ||
|
|
@@ -440,10 +428,6 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null | |
| if (fetchSourceContext != null) { | ||
| updateRequest.fetchSource(fetchSourceContext); | ||
| } | ||
| if (fields != null) { | ||
| updateRequest.fields(fields); | ||
| } | ||
|
|
||
| IndexRequest upsertRequest = updateRequest.upsertRequest(); | ||
| if (upsertRequest != null) { | ||
| upsertRequest.version(version); | ||
|
|
||
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.
Can you also add a note about the change you update request?
I'm not sure this is the right file for them but you may as well put them here for now and we'll move them if we decide there is a better spot.