PHP/Sphinxsearch - searching for string or lat lng

你。 提交于 2019-12-11 16:53:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!