-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил тестовый скрипт persistent-подключения
- Loading branch information
Sergey Shirokov
committed
Nov 6, 2018
1 parent
3ba75d0
commit b671c4e
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); |