Cloudsearch边界框过滤器

时间:2015-01-27 02:57:39

标签: php amazon-cloudsearch

我有以下CloudSearch查询

$query = array(
'query' => '(and expiry:[' . $time . ',} updatetime:[100,} type:\'all\')',
'queryParser' => 'structured',
'queryOptions' => '{"defaultOperator":"and"}',
'sort' => 'distance asc',
'return'=>'_all_fields,_score,distance',
'size' => 5000,
'expr'=> '{"distance":"haversin(' . $lat . ',' . $lon . ',location.latitude,location.longitude)"}',
'start'=>$start,
'fq'=>'location:[\'35.628611,-120.694152\',\'35.621966,-120.686706\']'

);

除了FQ部分之外,查询有效,意图是fq会将结果限制在边界框区域内。但尽管有它,但它并没有限制结果。远远超出该区域的结果正在返回,我需要更改此内容才能使其正常工作?

1 个答案:

答案 0 :(得分:3)

我有解决此问题的方法

尽管aws文档在示例中将其称为 fq ,但实际上 filterQuery

还要注意,位置点顺序是左上角,右下角

$query = array(
'query' => '(and expiry:[' . $time . ',} updatetime:[100,} type:\'all\')',
'queryParser' => 'structured',
'queryOptions' => '{"defaultOperator":"and"}',
'sort' => 'distance asc',
'return'=>'_all_fields,_score,distance',
'size' => 5000,
'expr'=> '{"distance":"haversin(' . $lat . ',' . $lon .          ',location.latitude,location.longitude)"}',
'start'=>$start,
'filterQuery'=>'location:[\'35.628611,-120.694152\',\'35.621966,-120.686706\']'

 );