Skip to content

Commit

Permalink
Added test file/example for VALUES and RANGE attribute filters, both …
Browse files Browse the repository at this point in the history
…working
  • Loading branch information
kurokikaze committed Jan 13, 2012
1 parent 9688a08 commit d517bc3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions testfilters.js
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);
}
});

0 comments on commit d517bc3

Please sign in to comment.