问题
I need to find all results where city name matches string OR latitude and longitute is between given values. My index looks like this:
sql_field_string = city
sql_attr_float = lat
sql_attr_float = lng
Is there any way to use attributes in query? Or can I use in query values from $s->setSelect()? I know I can easily filter results using $s->setFilterFloatRange() but OR condition is essential for me in this case.
This works fine:
$s->SetFilterFloatRange('lat', $_GET['lat'] - $_GET['distance'], $_GET['lat'] + $_GET['distance']);
$s->SetFilterFloatRange('lng', $_GET['lng'] - $_GET['distance'], $_GET['lng'] + $_GET['distance']);
$s->Query('@city Amsterdam');
but it gives me rows where city is Amsterdam AND lat, lng between given values, but my problem is that I don't need filter (AND condition) I need OR.
I also know that I can use:
$s->setSelect('*, IF(lat<11,1,0) AS latitude');
but I belive i could use the 'latitude' only as a filter.
来源:https://stackoverflow.com/questions/27708773/php-sphinxsearch-searching-for-string-or-lat-lng