简体   繁体   English

Cloudsearch边界框过滤器

[英]Cloudsearch bounding box filter

I have the following CloudSearch Query 我有以下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\']'

);

The query works except for the FQ part, the intention is that the fq would restrict the results to within a bounding box area. 查询除FQ部分外,其意图是fq会将结果限制在边界框区域内。 but despite having it there, its not restricting the results. 但尽管有它,但它并没有限制结果。 results far outside that region are returning, What do I need to change this to make it work correctly? 远远超出该区域的结果正在返回,我需要更改此内容才能使其正常工作?

I have the solution for this issue 我有解决这个问题的方法

Although the aws docs refer to it in examples as fq its actually filterQuery 尽管aws文档在示例中将其称为fq,但它实际上是filterQuery

also note that the location point order is top-left, bottom-right 另请注意,位置点顺序是左上角,右下角

$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\']'

 );

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

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