-
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.
Added test file/example for VALUES and RANGE attribute filters, both …
…working
- Loading branch information
1 parent
9688a08
commit d517bc3
Showing
1 changed file
with
39 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,39 @@ | ||
var limestone = require("./limestone").SphinxClient(); | ||
|
||
// 9312 is standard Sphinx port | ||
// | ||
var filter = { | ||
'type': 0, // VALUES | ||
'attr': 'author_id', | ||
'values':[1,4] | ||
}; | ||
|
||
var filter_range = { | ||
'type':1, // RANGE | ||
'attr':'author_id', | ||
'min':1, | ||
'max':3 | ||
} | ||
|
||
limestone.connect(9312, function(err) { | ||
if (!err) { | ||
limestone.query({'query':'document', indices:'testpipe2', filters:[filter]}, function(err, answer){ | ||
if (!err) { | ||
console.log("Extended search for 'test' on authors 1 and 4 yielded " + answer.match_count + " results: " + JSON.stringify(answer)); | ||
// limestone.disconnect(); | ||
limestone.query({'query':'document', indices:'testpipe2', filters:[filter_range]}, function(err, answer){ | ||
if (!err) { | ||
console.log("Extended search for 'test' on authors 1..3 yielded " + answer.match_count + " results: " + JSON.stringify(answer)); | ||
limestone.disconnect(); | ||
} else { | ||
console.log('Request 2 error: ' + err); | ||
} | ||
}); | ||
} else { | ||
console.log('Request error: ' + err); | ||
} | ||
}); | ||
} else { | ||
console.log('Error on search: ' + err); | ||
} | ||
}); |