Addresses #680, Implement left-bound search pref

Implemented for tags and the fulltext word index, which should speed things up a bit. Not implemented for notes and fields, since those might have multiple words -- would have to put them in the fulltext word index...
This commit is contained in:
Dan Stillman 2007-07-20 19:06:29 +00:00
parent ff654dbdda
commit 9d8c427d1e
3 changed files with 25 additions and 4 deletions

View File

@ -887,7 +887,7 @@ Zotero.ItemGroup.prototype.getChildItems = function()
var ids = s.search();
}
catch (e) {
if (e.match(/Saved search [0-9]+ does not exist/)) {
if (typeof e == 'string' && e.match(/Saved search [0-9]+ does not exist/)) {
Zotero.DB.rollbackTransaction();
Zotero.debug(e, 2);
return false;

View File

@ -584,6 +584,7 @@ Zotero.Search.prototype._buildQuery = function(){
field: data['field'],
operator: this._conditions[i]['operator'],
value: this._conditions[i]['value'],
flags: data['flags'],
required: this._conditions[i]['required']
});
@ -926,7 +927,14 @@ Zotero.Search.prototype._buildQuery = function(){
case 'contains':
case 'doesNotContain': // excluded with NOT IN above
condSQL += ' LIKE ?';
condSQLParams.push('%' + condition['value'] + '%');
if (condition['flags'] &&
condition['flags']['leftbound'] &&
Zotero.Prefs.get('search.useLeftBound')) {
condSQLParams.push(condition['value'] + '%');
}
else {
condSQLParams.push('%' + condition['value'] + '%');
}
break;
case 'is':
@ -1120,6 +1128,10 @@ Zotero.SearchConditions = new function(){
/*
* Define and set up the available advanced search conditions
*
* Flags:
* - special
* - template
*/
function _init(){
_conditions = [
@ -1266,7 +1278,10 @@ Zotero.SearchConditions = new function(){
doesNotContain: true
},
table: 'itemTags',
field: 'tag'
field: 'tag',
flags: {
leftbound: true
}
},
{
@ -1356,6 +1371,9 @@ Zotero.SearchConditions = new function(){
},
table: 'fulltextItemWords',
field: 'word',
flags: {
leftbound: true
},
special: true
},
@ -1414,11 +1432,13 @@ Zotero.SearchConditions = new function(){
sortValues[localized] = {
name: i,
localized: localized,
operators: _conditions[i]['operators']
operators: _conditions[i]['operators'],
flags: _conditions[i]['flags']
};
}
// Alphabetize by localized name
// TODO: locale collation sort
sortKeys = sortKeys.sort();
for each(var i in sortKeys){
_standardConditions.push(sortValues[i]);

View File

@ -38,6 +38,7 @@ pref("extensions.zotero.keys.copySelectedItemsToClipboard", 'C');
// Fulltext indexing
pref("extensions.zotero.fulltext.textMaxLength", 500000);
pref("extensions.zotero.fulltext.pdfMaxPages", 100);
pref("extensions.zotero.search.useLeftBound", true);
// Export and citation settings
pref("extensions.zotero.export.lastTranslator", '14763d24-8ba0-45df-8f52-b8d1108e7ac9');