开发者

Sphinx RT index returning huge @geodist even with floats and radians

After extensively reading all the posts I could find in the Sphinx forum and this site I'm still stuck. I've implemented a real-time index for geographic search using @geodist. Everything works, but the @geodist returns impossibly large values. The only support I could find on this suggested converting degrees to radians and using floats, but I've already done that. See my code below.

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

             开发者_StackOverflow   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
}

real-time index test data

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 code:

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
                                )
                )
)

I intend to use SetFilterFloatRange too but only after the numbers returned make sense. I'm hoping I simply missed something, but I can't find anything missing in the documentation. I appreciate any help you give!


I used this post and it helped me when I was having fun times too:

http://www.god-object.com/2009/10/20/geospatial-search-using-sphinx-search-and-php/

also, [@geodist] => 15278115 is expressed in meters

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜