是否可以限制嵌套字段的结果?

我有商店老板和商店,对于我的搜索结果,我只想获得2家商店,而不是所有者的所有元素。

我的设置是foselasticabundle 5.0 + elasticsearch 5.4.3

我已经尝试使用以下查询:

 $query = new Query(); $query->setParams( [ 'query' => [ 'bool' => [ 'must' => [ [ 'match' => [ '_all' => $term, ], ], [ 'nested' => [ 'path' => 'shops', 'score_mode' => 'max', 'inner_hits' => [ 'size' => 2, ], 'query' => [ 'match_all' => ['boost' => 1.0], ], ], ], ], ], ], ] ); $found = $this->index->getType('owner')->search($query); 

该查询有效,但是忽略了size参数

类型定义: types: owner: properties: name: { boost: 10, analyzer: snowball } created: { type: date } shops: type: nested properties: name: ~ address: type: nested properties: city: ~ street: ~ zip: ~ persistence: driver: orm model: AppBundle\\Entity\\Owner provider: ~ finder: ~

这是一个示例文档:

 { "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 4, "max_score": 1.0, "hits": [ { "_index": "app_dev", "_type": "owner", "_id": "9", "_score": 1.0, "_source": { "name": "Demo Name", "created": "2017-06-30T22:46:47+02:00", "shops": [ { "name": "Shop 1 ", "address": { "city": "Test", "street": "Teststreet 123", "zip": "1234" } }, { "name": "Shop 2", "address": { "city": "Test", "street": "Teststreet 123", "zip": "1234" } }, { "name": "Shop 3", "address": { "city": "Test", "street": "Teststreet 123", "zip": "1234" } } ] } } ] } } 

  ask by stackpi translate from so

本文未有回复,本站智能推荐: