From b671c4eba5836c55d61ad5a873b06eddf6cbbf88 Mon Sep 17 00:00:00 2001 From: Sergey Shirokov Date: Tue, 6 Nov 2018 19:22:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=81=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D1=82=20persistent-=D0=BF=D0=BE=D0=B4=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/persistent.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/persistent.js diff --git a/tests/persistent.js b/tests/persistent.js new file mode 100644 index 0000000..e430e8c --- /dev/null +++ b/tests/persistent.js @@ -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(); + }); + }); +}); \ No newline at end of file