[英]PHP Elasticsearch GET value of a field from all documents in index
I've an Elasticsearch with an index where all documents have the same fields. 我有一个带有索引的Elasticsearch,其中所有文档都具有相同的字段。 One of these fields is called "Company".
这些字段之一称为“公司”。
I want to create a PHP script that runs a query that gets the value of that field from all the documents in that index. 我想创建一个运行查询的PHP脚本,该查询从该索引中的所有文档中获取该字段的值。
How could I go about doing this? 我该怎么做呢? I'm using Elasticsearch 6.3 and PHP 7.2.
我正在使用Elasticsearch 6.3和PHP 7.2。
This does not work but should help in understanding what I'm trying to do: 这是行不通的,但应该有助于了解我要执行的操作:
$params = [
'index' => 'aksjeregisteret2017',
'type' => '_doc',
'field' => ['Company']
];
$response = $es->get($params);
@Ole Are you trying to query only the field 'Company'?If so just use '_source' instead of 'field' . @Ole您是否尝试仅查询字段'Company'?如果是,只需使用'_source'而不是'field'。 So your
所以你
$params = [
'index' => 'aksjeregisteret2017',
'type' => '_doc',
];
$params['body']['_source' ]= 'Company';
$params['body']['query']['match_all']['boost'] = 1.2;
$response = $es->search($params);
Reference: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html 参考: https : //www.elastic.co/guide/zh-CN/elasticsearch/reference/current/search-request-source-filtering.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.