我正在使用 sphinx 通过 nodejs 运行以下一组查询:-
sphClient.SetGeoAnchor("latitude", "longitude", lat, long);
sphClient.SetFilterRange("@geodist",0,1000);
var res = sphClient.Query("@country country_name");
但是,当我运行它时,它给了我以下错误:-
throw new assert.AssertionError({
^
AssertionError: "number" == "float"
at SphinxClient.SetGeoAnchor (/node_modules/sphinxapi/lib/sphinxapi.js:395:9)
at Socket.<anonymous> (/node_modules/posts/egx.js:331:15)
at Socket.EventEmitter.emit [as $emit] (events.js:95:17)
at SocketNamespace.handlePacket (/node_modules/socket.io/lib/namespace.js:335:22)
at Manager.onClientMessage (/node_modules/socket.io/lib/manager.js:488:38)
at WebSocket.Transport.onMessage (/node_modules/socket.io/lib/transport.js:387:20)
at Parser.<anonymous> (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10)
at Parser.EventEmitter.emit (events.js:95:17)
at finish (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:288:16)
at Parser.expectHandler (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:299:15)
我什至明白问题出在哪里,在查看 sphinxapi.js 后,我发现它将 typeof(lat) 、 typeof(long) 与 "float" 进行比较,但是 nodejs 只返回 "number" 。我试过 parseFloat 。还将比较更改为“数字”会给我另一个错误,例如:-
/node_modules/sphinxapi/lib/sphinxapi.js:79
l += Number( obj.hasOwnProperty(k) );
^
ReferenceError: obj is not defined
at len (/node_modules/sphinxapi/lib/sphinxapi.js:79:17)
at SphinxClient.AddQuery (/node_modules/sphinxapi/lib/sphinxapi.js:572:6)
at SphinxClient.Query (/node_modules/sphinxapi/lib/sphinxapi.js:476:7)
at Socket.<anonymous> (/node_modules/posts/egx.js:333:25)
at Socket.EventEmitter.emit [as $emit] (events.js:95:17)
at SocketNamespace.handlePacket (/node_modules/socket.io/lib/namespace.js:335:22)
at Manager.onClientMessage (/node_modules/socket.io/lib/manager.js:488:38)
at WebSocket.Transport.onMessage (/node_modules/socket.io/lib/transport.js:387:20)
at Parser.<anonymous> (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10)
at Parser.EventEmitter.emit (events.js:95:17)