Result Reading
Document queries without a field projection expose the original document in _DOC. With the default preRead=true, fields are also expanded for entity mapping.
Read Selected Fields
An explicit _source field list defines the result columns and their order, so scalar, list and Pairs methods can read them directly. This also works with preRead=false.
Ordinary field projections require permission to read index mappings. Read binary fields as byte[] and date or date_nanos fields as Timestamp.
With doc_values disabled or a custom date format, values that cannot be normalized remain in their original form. Use ISO dates or enable doc_values when date conversion is needed.
List<String> names = jdbc.queryForList(
"POST /user_info/_search {\"_source\": [\"name\"], \"query\": {\"term\": {\"uid\": ?}}}",
new Object[] { "1001" }, String.class);
Wildcard, exclusion-based or unspecified projections keep the document result format below.
Read a Field by Name
The first document-result column is _ID. Read business fields by name:
List<String> names = jdbc.queryForList(
"POST /user_info/_search {\"query\":{\"term\":{\"uid\": ?}}}",
new Object[] { "1001" },
(rs, rowNum) -> rs.getString("name"));
With preRead=false, read the original document instead of expecting expanded columns:
List<String> documents = jdbc.queryForList(
"POST /user_info/_search {\"size\":10,\"query\":{\"match_all\":{}}}",
(rs, rowNum) -> rs.getString("_DOC"));
For nested objects and arrays, getString() returns JSON; getObject() with an explicit field projection returns a Map or List. Configure JSON mapping for structured entity properties.
Limit the Returned Data
The driver reads only this REST response. Set size or use Pagination; queryForList does not automatically fetch all search pages.
For JSON-to-object mapping, see JSON Field Mapping.