-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
HLRC for _mtermvectors #35266
Merged
mayya-sharipova
merged 4 commits into
elastic:master
from
mayya-sharipova:rhlc-multi-term-vectors
Nov 19, 2018
Merged
HLRC for _mtermvectors #35266
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
.../rest-high-level/src/main/java/org/elasticsearch/client/core/MultiTermVectorsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.core; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.elasticsearch.client.core.TermVectorsRequest.createFromTemplate; | ||
|
||
public class MultiTermVectorsRequest implements ToXContentObject, Validatable { | ||
|
||
private List<TermVectorsRequest> requests = new ArrayList<>(); | ||
|
||
/** | ||
* Constructs an empty MultiTermVectorsRequest | ||
* After that use {@code add} method to add individual {@code TermVectorsRequest} to it. | ||
*/ | ||
public MultiTermVectorsRequest() {}; | ||
|
||
/** | ||
* Constructs a MultiTermVectorsRequest from the given document ids | ||
* and a template {@code TermVectorsRequest}. | ||
* Used when individual requests share the same index, type and other settings. | ||
* @param ids - ids of documents for which term vectors are requested | ||
* @param template - a template {@code TermVectorsRequest} that allows to set all | ||
* settings only once for all requests. | ||
*/ | ||
public MultiTermVectorsRequest(String[] ids, TermVectorsRequest template) { | ||
for (String id : ids) { | ||
TermVectorsRequest request = createFromTemplate(template, id); | ||
requests.add(request); | ||
} | ||
} | ||
|
||
/** | ||
* Adds another {@code TermVectorsRequest} to this {@code MultiTermVectorsRequest} | ||
* @param request - {@code TermVectorsRequest} to add | ||
*/ | ||
public void add(TermVectorsRequest request) { | ||
requests.add(request); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.startArray("docs"); | ||
for (TermVectorsRequest request : requests) { | ||
request.toXContent(builder, params); | ||
} | ||
builder.endArray(); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...rest-high-level/src/main/java/org/elasticsearch/client/core/MultiTermVectorsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.core; | ||
|
||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
public class MultiTermVectorsResponse { | ||
private final List<TermVectorsResponse> responses; | ||
|
||
public MultiTermVectorsResponse(List<TermVectorsResponse> responses) { | ||
this.responses = responses; | ||
} | ||
|
||
private static ConstructingObjectParser<MultiTermVectorsResponse, Void> PARSER = | ||
new ConstructingObjectParser<>("multi_term_vectors", true, | ||
args -> { | ||
// as the response comes from server, we are sure that args[0] will be a list of TermVectorsResponse | ||
@SuppressWarnings("unchecked") List<TermVectorsResponse> termVectorsResponsesList = (List<TermVectorsResponse>) args[0]; | ||
return new MultiTermVectorsResponse(termVectorsResponsesList); | ||
} | ||
); | ||
|
||
static { | ||
PARSER.declareObjectArray(constructorArg(), (p,c) -> TermVectorsResponse.fromXContent(p), new ParseField("docs")); | ||
} | ||
|
||
public static MultiTermVectorsResponse fromXContent(XContentParser parser) { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
/** | ||
* Returns the list of {@code TermVectorsResponse} for this {@code MultiTermVectorsResponse} | ||
*/ | ||
public List<TermVectorsResponse> getTermVectorsResponses() { | ||
return responses; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) return true; | ||
if (!(obj instanceof MultiTermVectorsResponse)) return false; | ||
MultiTermVectorsResponse other = (MultiTermVectorsResponse) obj; | ||
return Objects.equals(responses, other.responses); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(responses); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -670,7 +670,6 @@ public void testApiNamingConventions() throws Exception { | |
"indices.exists_type", | ||
"indices.get_upgrade", | ||
"indices.put_alias", | ||
"mtermvectors", | ||
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. yay! |
||
"render_search_template", | ||
"scripts_painless_execute", | ||
"tasks.get" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I know @jtibshirani has done some work on removing types from 7.0, and I dont know how this may or may not be impacted. @jtibshirani does this need to be different at all based on the work you did in #35421 ?
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.
Thanks for the ping! I don't think we need to worry about it in this PR. We'll do a separate pass through each affected API to add the right deprecations (including the Java HLRC).