我正在使用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)
答案 0 :(得分:0)
javascript只有一种类型的数字是&#34; double&#34;。没有整数,浮点数等 无论您正在测试什么类型的号码,您总能获得&#34; number&#34;结果:
typeof 1是&#34; number&#34;
typeof 1.1是&#34; number&#34;
我不知道sphinx typeof()里面发生了什么,但一切都是&#34;数字&#34;是正常的。 请将代码或链接发布到我可以找到代码的位置。它会帮助我帮助你解决这个问题。