简体   繁体   English

如何通过 PHP v2 SDK 从 AWS CloudSearch 请求方面?

[英]How to request facets from AWS CloudSearch via the PHP v2 SDK?

I am using v2 of the PHP SDK for interfacing requests to AWS CloudSearch.我正在使用 PHP SDK 的 v2 将请求连接到 AWS CloudSearch。 T he documentation is here , however details and examples are somewhat lacking. 文档在这里,但是细节和示例有些缺乏。 I need to include facets in my search.我需要在我的搜索中包括方面。 It is clearly asking for a string but it is not clear exactly how the string should be formatted.它显然要求一个字符串,但不清楚该字符串的确切格式。

$cloudSearchDomainClient->serach([
    'filterQuery' => $filter,
    'query' => $query,
    'queryParser' => 'lucene',
    'facet' => '???'
]);

I have tried, for example:我试过,例如:

'facet' => 'field1,field2,field3'

'facet' => 'facet.fieldname={sort:'count',size:5}'

'facet' => 'fieldname={sort:'count',size:5}'

(Some permutations based on examples in the non-sdk request descriptions here ) (基于此处非 sdk 请求描述中的示例的一些排列)

The appropriate syntax appears to be a string representing a javascript object.适当的语法似乎是表示 javascript 对象的字符串。

For the default sort/count:对于默认排序/计数:

'facet' => '{fieldname:{}}'

To specify sorting options:要指定排序选项:

'faceet' => '{fieldname:{'sort':'count',size:5}}'

To request multiple facets:要请求多个方面:

'facet' => '{field1:{},field2"{}}"

Etc.等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM