Skip to content

Commit

Permalink
Добавил тестовый скрипт persistent-подключения
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Shirokov committed Nov 6, 2018
1 parent 3ba75d0 commit b671c4e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/persistent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const limestone = require('../limestone').SphinxClient();

const testString = 'Punk';

// 9312 is standard Sphinx port
limestone.connect(9312, true, (connErr) => {
if (connErr) {
console.log(`Connection error: ${connErr.message}`);
console.log('Maybe Sphinx is not started or uses port different than 9312');
process.exit();
}

const query = (callback) => {
limestone.query({
query: 'Punk',
maxmatches: 1,
fieldweights: {
name: 80,
desc: 30,
},
}, callback);
};

query((firstErr, firstAnswer) => {
console.log(`First search for ${testString} yielded ${firstAnswer.match_count} results.`);
query((secondErr, secondAnswer) => {
console.log(`Second search for ${testString} yielded ${secondAnswer.match_count} results.`);
limestone.disconnect();
});
});
});

0 comments on commit b671c4e

Please sign in to comment.