Nodejs中的limestone模块使用nodejs和sphinx抛出错误

时间:2012-03-01 15:33:40

标签: node.js sphinx npm

我一直在尝试将sphinx服务器与nodejs和limestone模块连接起来。但它抛出的错误如下。请帮帮我。

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: ENOENT, No such file or directory
    at doConnect (net.js:549:5)
    at Socket.connect (net.js:709:5)
    at Object.createConnection (net.js:265:5)
    at Object.connect (/home/node/node_modules/limestone/limestone.js:129:23)
    at Object.<anonymous> (/home/node/www/bmchat-new/sphinx-connect.js:4:15)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)
    at Function._load (module.js:302:12)
    at Array.<anonymous> (module.js:430:10)

sphinx-connect.js的源代码

var limestone = require("limestone").SphinxClient(),
sys = require("sys");

limestone.connect("192.168.2.168:9312", // port. 9312 is standard Sphinx port. also 'host:port' allowed
    function(err) { // callback
      if (err) {
          sys.puts('Connection error: ' + err);
      }

      sys.puts('Connected, sending query');
      limestone.query(
          {'query':'test', maxmatches:1}, 
          function(err, answer) {
          limestone.disconnect();
          sys.puts("Extended search for 'test' yielded " + 
               answer.match_count + " results: " + 
               JSON.stringify(answer));
          });         
     });

1 个答案:

答案 0 :(得分:2)

问题是我使用的是从npm(v1.0.106)获得的旧的limestone.js。所以更新后的,你可以从github

获得

发现的问题是旧的limestone.js使用server_conn = tcp.createConnection(port);而不是下面的server_conn = tcp.createConnection(port, host);