Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,51 @@ setup:

- match: { hits.hits.0.fields.integer.0: 42 }
- is_false: hits.hits.1.fields.integer

---
"Test disable _source loading":
- do:
indices.create:
index: test
body:
settings:
number_of_shards: 1
mappings:
properties:
keyword:
type: keyword
integer:
type: integer
store: true

- do:
index:
index: test
id: 1
body:
keyword: "x"
integer: 42

- do:
Copy link
Member

Choose a reason for hiding this comment

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

I tend to stick refresh on the index request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 this is nicer, especially when there's only one index request.

indices.refresh:
index: [ test ]

- do:
search:
index: test
body:
fields: [ keyword ]
_source: false

- match: { hits.hits.0.fields.keyword.0: "x" }

- do:
search:
index: test
body:
fields: [ keyword ]
stored_fields: [ integer ]
_source: false

- match: { hits.hits.0.fields.keyword.0: "x" }
- match: { hits.hits.0.fields.integer.0: 42 }
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void execute(SearchContext context) {
}
}
}
boolean loadSource = context.sourceRequested();
boolean loadSource = context.sourceRequested() || context.fetchFieldsContext() != null;
if (storedToRequestedFields.isEmpty()) {
// empty list specified, default to disable _source if no explicit indication
fieldsVisitor = new FieldsVisitor(loadSource);
Expand Down