ES搜索查询调用并仅返回选定的字段

时间:2013-04-18 08:48:26

标签: elasticsearch

我正在尝试为Elastic Search编写一个返回前20个最接近匹配的查询。

我想返回标题字段的前20个匹配项。

curl -X POST "localhost:9200/xxx/_search?pretty=true" -d '
{
"from" : 0,
"size" : 20,
"query" : { "term" : {"title" : "art"} }}'

我在这里缺少什么?

更新

我试图只返回'title'字段,而不是整个对象。

1 个答案:

答案 0 :(得分:1)

我通过使用字段param进行搜索得到了这个:

curl -X POST "localhost:9200/xxx/_search?pretty=true" -d '
{
"from" : 0,
"size" : 20,
"fields" : ["title"],
"query" : { "term" : {"title" : "art"} }}'
相关问题