简体   繁体   中英

Cloudsearch bounding box filter

I have the following CloudSearch Query

$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. 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

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

 );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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