Closed mahendran-kcube closed 2 years ago
Here the code to have the same output as your raw query (order of instructions are not in the same exact order):
$aggregate
->withIndexName('indexName ')
->withLoad(['@geofield'])
->withQuery($query)
->withApplies(['@cc_sum * ( 20 - (geodistance(@geofield, -83.81373, 34.3755452645611)) / 20)' => 'ccSumCalcValue', '1 ' => 'test'])
->addGroupBy(['test'], [MacFJA\RediSearch\Aggregate\Reducer::sum('ccSumCalcValue', 'weightedSum')]);
There is indeed a small issue with the APPLY 1 as test
as the value of the applier (1
) is not consider as a string, but with an extra space, the value is forced to be a string
Aggregate Raw query
FT.AGGREGATE indexName "@geofield:[-83.81373 34.3755452645611 20 mi]" LOAD 1 @geofield APPLY "@cc_sum * ( 20 - (geodistance(@geofield, -83.81373, 34.3755452645611)) / 20)" as ccSumCalcValue APPLY 1 as test GROUPBY 1 @test REDUCE SUM 1 @ccSumCalcValue as weightedSum
Aggregate query using the "MacFJA/php-redisearch"
I am not able to do the following command from raw aggregate query using this library
APPLY 1 as test GROUPBY 1 @test REDUCE SUM 1 @ccSumCalcValue as weightedSum
Can someone help me out to do this command using this library