0
在廣泛閱讀我可以在獅身人面像論壇和本網站找到的所有帖子後,我仍然卡住。我已經使用@geodist實現了地理搜索的實時索引。一切正常,但@geodist返回不可能的大值。我能找到的唯一支持建議將度數轉換爲弧度並使用浮點數,但我已經這樣做了。看到我的代碼如下。獅身人面像RT指數返回巨大@geodist即使浮動和弧度
的sphinx.conf:
index rt_deals
{
type = rt
rt_mem_limit = 32M
path = /var/lib/sphinx/rt_deals
charset_type = sbcs
charset_table = 0..9, A..Z->a..z, a..z, U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, $
rt_field = deal_types
rt_attr_uint = venue_id
rt_attr_float = venue_latitude
rt_attr_float = venue_longitude
rt_attr_timestamp = dt_start
rt_attr_timestamp = dt_end
}
indexer
{
mem_limit = 32M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = /var/log/sphinx/searchd.log
query_log = /var/log/sphinx/query.log
read_timeout = 5
max_children = 30
pid_file = /var/run/sphinx/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
workers = threads # for RT to work
}
實時索引測試數據
INSERT INTO rt_deals (id,deal_types,venue_id,venue_latitude,venue_longitude) VALUES
(46,'b',41,0.7390897867826055,-1.2415384027937675), (45,'b
c',42,0.7387899148438626,-1.24255786085905);
PHP代碼:
include('include/sphinxapi.php');
$_longitude = '42.358431';
$_latitude = '-71.059773';
$search = new SphinxClient();
$search->SetServer('[SERVER IP REMOVED]', 9312);
$search->SetConnectTimeout(1);
$search->SetArrayResult(true);
$search->SetMatchMode(SPH_MATCH_ALL);
$search->SetGeoAnchor('venue_latitude', 'venue_longitude', (float)deg2rad($_latitude),
(float)deg2rad($_longitude));
$search->SetSelect('*');
$search->SetLimits(0, 100);
$result = $search->Query('b', 'rt_deals');
# results, print_r($result):
Array
(
[error] =>
[warning] =>
[status] => 0
[fields] => Array
(
[0] => deal_types
)
[attrs] => Array
(
[venue_id] => 1
[venue_latitude] => 5
[venue_longitude] => 5
[dt_start] => 2
[dt_end] => 2
[@geodist] => 5
)
[matches] => Array
(
[0] => Array
(
[id] => 45
[weight] => 1
[attrs] => Array
(
[venue_id] => 42
[venue_latitude] => 0.73878991603851
[venue_longitude] => -1.2425578832626
[dt_start] => 0
[dt_end] => 0
[@geodist] => 15278498
)
)
[1] => Array
(
[id] => 46
[weight] => 1
[attrs] => Array
(
[venue_id] => 41
[venue_latitude] => 0.73908978700638
[venue_longitude] => -1.2415384054184
[dt_start] => 0
[dt_end] => 0
[@geodist] => 15278115
)
)
)
[total] => 2
[total_found] => 2
[time] => 0.000
[words] => Array
(
[b] => Array
(
[docs] => 2
[hits] => 2
)
)
)
我打算用SetFilterFloatRange太多,但返回的號碼後,才合理。 我希望我只是錯過了一些東西,但我找不到 文檔中缺少的任何東西。我感謝您給予的任何幫助!