mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-24 17:09:48 +00:00
Rename isSourceEmpty to hasSource
And add a test case for {} to reindex.
This commit is contained in:
parent
c2e745bf3b
commit
cca3154c43
@ -108,9 +108,10 @@ public interface SearchHit extends Streamable, ToXContent, Iterable<SearchHitFie
|
||||
byte[] source();
|
||||
|
||||
/**
|
||||
* Is the source empty (not available) or not.
|
||||
* Is the source available or not. A source with no fields will return true. This will return false if {@code fields} doesn't contain
|
||||
* {@code _source} or if source is disabled in the mapping.
|
||||
*/
|
||||
boolean isSourceEmpty();
|
||||
boolean hasSource();
|
||||
|
||||
/**
|
||||
* The source of the document as a map (can be <tt>null</tt>).
|
||||
|
@ -240,7 +240,7 @@ public class InternalSearchHit implements SearchHit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSourceEmpty() {
|
||||
public boolean hasSource() {
|
||||
return source == null;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||
assertNoFailures(response);
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3L));
|
||||
assertThat(response.getHits().getAt(0).isSourceEmpty(), equalTo(true));
|
||||
assertThat(response.getHits().getAt(0).hasSource(), equalTo(true));
|
||||
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
||||
Set<String> fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
|
@ -86,7 +86,7 @@ public abstract class AbstractAsyncBulkIndexByScrollAction<
|
||||
Map<String, Object> scriptCtx = null;
|
||||
|
||||
for (SearchHit doc : docs) {
|
||||
if (doc.isSourceEmpty()) {
|
||||
if (doc.hasSource()) {
|
||||
/*
|
||||
* Either the document didn't store _source or we didn't fetch it for some reason. Since we don't allow the user to
|
||||
* change the "fields" part of the search request it is unlikely that we got here because we didn't fetch _source.
|
||||
|
@ -374,3 +374,30 @@
|
||||
index: new_twitter
|
||||
type: tweet
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
---
|
||||
"Source document without any fields works":
|
||||
- do:
|
||||
index:
|
||||
index: source
|
||||
type: foo
|
||||
id: 1
|
||||
body: {}
|
||||
- do:
|
||||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
reindex:
|
||||
body:
|
||||
source:
|
||||
index: source
|
||||
dest:
|
||||
index: dest
|
||||
- match: {created: 1}
|
||||
|
||||
- do:
|
||||
get:
|
||||
index: dest
|
||||
type: foo
|
||||
id: 1
|
||||
- match: { _source: {} }
|
||||
|
@ -226,3 +226,27 @@
|
||||
index: test
|
||||
scroll_size: 1
|
||||
- match: {batches: 3}
|
||||
|
||||
---
|
||||
"Source document without any fields works":
|
||||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: foo
|
||||
id: 1
|
||||
body: {}
|
||||
- do:
|
||||
indices.refresh: {}
|
||||
|
||||
- do:
|
||||
update_by_query:
|
||||
index: test
|
||||
- match: {updated: 1}
|
||||
|
||||
- do:
|
||||
get:
|
||||
index: test
|
||||
type: foo
|
||||
id: 1
|
||||
- match: { _source: {} }
|
||||
- match: { _version: 2 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user