Commit bd4765db authored by Xiaowu Zhang's avatar Xiaowu Zhang

queries: add support for chinese character research

parent 777b1010
...@@ -162,7 +162,7 @@ switch( state ) ...@@ -162,7 +162,7 @@ switch( state )
case 15: case 15:
if( info.src.charCodeAt( pos ) == 34 ) state = 7; if( info.src.charCodeAt( pos ) == 34 ) state = 7;
else if( ( info.src.charCodeAt( pos ) >= 0 && info.src.charCodeAt( pos ) <= 33 ) || ( info.src.charCodeAt( pos ) >= 35 && info.src.charCodeAt( pos ) <= 91 ) || ( info.src.charCodeAt( pos ) >= 93 && info.src.charCodeAt( pos ) <= 254 ) ) state = 15; else if( ( info.src.charCodeAt( pos ) >= 0 && info.src.charCodeAt( pos ) <= 33 ) || ( info.src.charCodeAt( pos ) >= 35 && info.src.charCodeAt( pos ) <= 91 ) || ( info.src.charCodeAt( pos ) >= 93 && info.src.charCodeAt( pos ) <= 254 ) || info.src.charCodeAt( pos ) > 255 ) state = 15;
else if( info.src.charCodeAt( pos ) == 92 ) state = 17; else if( info.src.charCodeAt( pos ) == 92 ) state = 17;
else state = -1; else state = -1;
break; break;
......
...@@ -101,6 +101,53 @@ ...@@ -101,6 +101,53 @@
}).always(start); }).always(start);
}); });
test('Chinese Character', function () {
var doc_list = [
{"identifier": ["测试一", "测试四"]},
{"identifier": ["测试一", "测试五"]},
{"identifier": ["a", "b"]}
];
stop();
jIO.QueryFactory.create(
'(identifier: "%测试一%" OR identifier: "%测试二%") AND identifier: "%测试四%"'
)
.exec(
doc_list
).then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": ["测试一", "测试四"]}
], 'Only first document should be kept');
doc_list = [
{"identifier": ["测试一", "测试四"]},
{"identifier": ["测试一", "测试五"]},
{"identifier": ["测试四", "b"]}
];
return jIO.QueryFactory.create('identifier: "%测试%"')
.exec(doc_list);
})
.then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": ["测试一", "测试四"]},
{"identifier": ["测试一", "测试五"]},
{"identifier": ["测试四", "b"]}
], 'All document should be kept');
doc_list = [
{"identifier": "测试一"},
{"identifier": "测试一", "title": "标题"},
{"identifier": "测试一", "title": "b"}
];
return jIO.QueryFactory.create('identifier: "%测试%" AND title: "标题"')
.exec(doc_list);
})
.then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": "测试一", "title": "标题"}
], 'Only second document should be kept');
}).always(start);
});
test('Wildcard Character', function () { test('Wildcard Character', function () {
var doc_list = [ var doc_list = [
{"identifier": "a"}, {"identifier": "a"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment