ES搜索查询调用并仅返回选定的字段 [英] ES search query call and return only selected fields
本文介绍了ES搜索查询调用并仅返回选定的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要返回前20个匹配的标题字段。
curl -X POSTlocalhost:9200 / xxx / _search?pretty = true-d'
{
from:0,
size:20,
query:{term:{title:art}}}'
我在这里缺少什么?
更新:
我只想得到返回的'title'字段,而不是整个对象。
解决方案
我通过搜索字段param获得了这一点:
curl -X POSTlocalhost:9200 / xxx / _search?pretty = true-d'
{
from:0,
size:20,
fields:[title
query:{term:{title:art}}}'
I'm trying to write a query for Elastic Search that would return the first 20 closest matches.
I want to return the first 20 matches for the title field.
curl -X POST "localhost:9200/xxx/_search?pretty=true" -d '
{
"from" : 0,
"size" : 20,
"query" : { "term" : {"title" : "art"} }}'
What am I missing here?
Update:
I'm trying to get only the 'title' field returned, not the whole object.
解决方案
I got this by doing a search with fields param:
curl -X POST "localhost:9200/xxx/_search?pretty=true" -d '
{
"from" : 0,
"size" : 20,
"fields" : ["title"],
"query" : { "term" : {"title" : "art"} }}'
这篇关于ES搜索查询调用并仅返回选定的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文