MST

星途 面试题库

面试题:ElasticSearch GET API选择字段时的复杂场景处理

在ElasticSearch的一个索引`books`中,文档类型为`book`,文档结构包含嵌套对象,例如`author`对象有`name`和`bio`字段,`book`本身有`title`、`publication_date`字段。现在要通过GET API获取`title`,以及`author`对象中的`name`字段,该如何构造请求?
20.2万 热度难度
数据库ElasticSearch

知识考点

AI 面试

面试题答案

一键面试
GET books/book/_search
{
    "_source": ["title", "author.name"],
    "query": {
        "match_all": {}
    }
}