Skip to content
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

Make typeless APIs usable with indices whose type name is different from _doc #35790

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
"bulk without types on an index that has types":

- skip:
version: " - 6.99.99"
reason: Typeless APIs were introduced in 7.0.0

- do:
indices.create: # not using include_type_name: false on purpose
index: index
body:
mappings:
not_doc:
properties:
foo:
type: "keyword"
- do:
bulk:
refresh: true
body:
- index:
_index: index
_id: 0
- foo: bar
- index:
_index: index
_id: 1
- foo: bar

- do:
count:
index: index

- match: {count: 2}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
"mtermvectors without types on an index that has types":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment: inconsistent spacing in this test (extra newline in mtermvectors.body.docs, spaces before :).


- skip:
version: " - 6.99.99"
reason: Typeless APIs were introduced in 7.0.0

- do:
indices.create: # not using include_type_name: false on purpose
index: index
body:
mappings:
not_doc:
properties:
foo:
type : "text"
term_vector : "with_positions_offsets"

- do:
index:
index: index
id: 1
body: { foo: bar }

- do:
mtermvectors:
body :
docs:
-
_index : index
_id : 1

- match: {docs.0.term_vectors.foo.terms.bar.term_freq: 1}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.mapper.MapperService;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -101,6 +102,7 @@ public void add(TermVectorsRequest template, @Nullable XContentParser parser) th
throw new IllegalArgumentException("docs array element should include an object");
}
TermVectorsRequest termVectorsRequest = new TermVectorsRequest(template);
termVectorsRequest.type(MapperService.SINGLE_MAPPING_NAME);
TermVectorsRequest.parseRequest(termVectorsRequest, parser);
add(termVectorsRequest);
}
Expand Down