query now supports regexes
actually compile stuff :/
This commit is contained in:
7
dist/recline.dataset.js
vendored
7
dist/recline.dataset.js
vendored
@@ -727,9 +727,12 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
this._applyFreeTextQuery = function(results, queryObj) {
|
this._applyFreeTextQuery = function(results, queryObj) {
|
||||||
if (queryObj.q) {
|
if (queryObj.q) {
|
||||||
var terms = queryObj.q.split(' ');
|
var terms = queryObj.q.split(' ');
|
||||||
|
var patterns=_.map(terms, function(term) {
|
||||||
|
return new RegExp(term.toLowerCase());;
|
||||||
|
});
|
||||||
results = _.filter(results, function(rawdoc) {
|
results = _.filter(results, function(rawdoc) {
|
||||||
var matches = true;
|
var matches = true;
|
||||||
_.each(terms, function(term) {
|
_.each(patterns, function(pattern) {
|
||||||
var foundmatch = false;
|
var foundmatch = false;
|
||||||
_.each(self.fields, function(field) {
|
_.each(self.fields, function(field) {
|
||||||
var value = rawdoc[field.id];
|
var value = rawdoc[field.id];
|
||||||
@@ -740,7 +743,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
// TODO regexes?
|
// TODO regexes?
|
||||||
foundmatch = foundmatch || (value.toLowerCase() === term.toLowerCase());
|
foundmatch = foundmatch || (pattern.test(value.toLowerCase()));
|
||||||
// TODO: early out (once we are true should break to spare unnecessary testing)
|
// TODO: early out (once we are true should break to spare unnecessary testing)
|
||||||
// if (foundmatch) return true;
|
// if (foundmatch) return true;
|
||||||
});
|
});
|
||||||
|
|||||||
7
dist/recline.js
vendored
7
dist/recline.js
vendored
@@ -1032,9 +1032,12 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
this._applyFreeTextQuery = function(results, queryObj) {
|
this._applyFreeTextQuery = function(results, queryObj) {
|
||||||
if (queryObj.q) {
|
if (queryObj.q) {
|
||||||
var terms = queryObj.q.split(' ');
|
var terms = queryObj.q.split(' ');
|
||||||
|
var patterns=_.map(terms, function(term) {
|
||||||
|
return new RegExp(term.toLowerCase());;
|
||||||
|
});
|
||||||
results = _.filter(results, function(rawdoc) {
|
results = _.filter(results, function(rawdoc) {
|
||||||
var matches = true;
|
var matches = true;
|
||||||
_.each(terms, function(term) {
|
_.each(patterns, function(pattern) {
|
||||||
var foundmatch = false;
|
var foundmatch = false;
|
||||||
_.each(self.fields, function(field) {
|
_.each(self.fields, function(field) {
|
||||||
var value = rawdoc[field.id];
|
var value = rawdoc[field.id];
|
||||||
@@ -1045,7 +1048,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
// TODO regexes?
|
// TODO regexes?
|
||||||
foundmatch = foundmatch || (value.toLowerCase() === term.toLowerCase());
|
foundmatch = foundmatch || (pattern.test(value.toLowerCase()));
|
||||||
// TODO: early out (once we are true should break to spare unnecessary testing)
|
// TODO: early out (once we are true should break to spare unnecessary testing)
|
||||||
// if (foundmatch) return true;
|
// if (foundmatch) return true;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user