mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
Refactor an ambigious TermVectorsRequest constructor. (#35614)
This commit is contained in:
parent
d62bbca56d
commit
4fea6b6f9b
@ -33,6 +33,8 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
||||
private final String index;
|
||||
private final String type;
|
||||
private String id = null;
|
||||
private XContentBuilder docBuilder = null;
|
||||
|
||||
private String routing = null;
|
||||
private String preference = null;
|
||||
private boolean realtime = true;
|
||||
@ -44,7 +46,6 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
||||
private boolean requestTermStatistics = false;
|
||||
private Map<String, String> perFieldAnalyzer = null;
|
||||
private Map<String, Integer> filterSettings = null;
|
||||
private XContentBuilder docBuilder = null;
|
||||
|
||||
|
||||
/**
|
||||
@ -54,7 +55,8 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
||||
* @param docId - id of the document
|
||||
*/
|
||||
public TermVectorsRequest(String index, String type, String docId) {
|
||||
this(index, type);
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.id = docId;
|
||||
}
|
||||
|
||||
@ -62,10 +64,12 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
||||
* Constructs TermVectorRequest for an artificial document
|
||||
* @param index - index of the document
|
||||
* @param type - type of the document
|
||||
* @param docBuilder - an artificial document
|
||||
*/
|
||||
public TermVectorsRequest(String index, String type) {
|
||||
public TermVectorsRequest(String index, String type, XContentBuilder docBuilder) {
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.docBuilder = docBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1154,10 +1154,10 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
||||
}
|
||||
{
|
||||
// test _termvectors on artificial documents
|
||||
TermVectorsRequest tvRequest = new TermVectorsRequest(sourceIndex, "_doc");
|
||||
XContentBuilder docBuilder = XContentFactory.jsonBuilder();
|
||||
docBuilder.startObject().field("field", "valuex").endObject();
|
||||
tvRequest.setDoc(docBuilder);
|
||||
|
||||
TermVectorsRequest tvRequest = new TermVectorsRequest(sourceIndex, "_doc", docBuilder);
|
||||
TermVectorsResponse tvResponse = execute(tvRequest, highLevelClient()::termvectors, highLevelClient()::termvectorsAsync);
|
||||
|
||||
TermVectorsResponse.TermVector.Token expectedToken = new TermVectorsResponse.TermVector.Token(0, 6, 0, null);
|
||||
|
@ -1565,10 +1565,12 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
||||
|
||||
{
|
||||
// tag::term-vectors-request-artificial
|
||||
TermVectorsRequest request = new TermVectorsRequest("authors", "_doc");
|
||||
|
||||
XContentBuilder docBuilder = XContentFactory.jsonBuilder();
|
||||
docBuilder.startObject().field("user", "guest-user").endObject();
|
||||
request.setDoc(docBuilder); // <1>
|
||||
TermVectorsRequest request = new TermVectorsRequest("authors",
|
||||
"_doc",
|
||||
docBuilder); // <1>
|
||||
// end::term-vectors-request-artificial
|
||||
|
||||
// tag::term-vectors-request-optional-arguments
|
||||
|
Loading…
x
Reference in New Issue
Block a user