0

我正在使用 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)
4

1 回答 1

0

javascript 只有一种类型的数字,即“double”。没有整数、浮点数等。无论您正在测试什么类型的数字,您总是得到“数字”作为结果:

typeof 1 是“数字”

typeof 1.1 是“数字”

我不知道 sphinx typeof() 内部发生了什么,但一切都是“数字”是正常的。请将代码或链接发布到我可以找到代码的位置。它将帮助我帮助您完成此过程。

于 2013-06-19T09:40:32.090 回答