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:
parent
ff654dbdda
commit
9d8c427d1e
|
@ -887,7 +887,7 @@ Zotero.ItemGroup.prototype.getChildItems = function()
|
||||||
var ids = s.search();
|
var ids = s.search();
|
||||||
}
|
}
|
||||||
catch (e) {
|
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.DB.rollbackTransaction();
|
||||||
Zotero.debug(e, 2);
|
Zotero.debug(e, 2);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -584,6 +584,7 @@ Zotero.Search.prototype._buildQuery = function(){
|
||||||
field: data['field'],
|
field: data['field'],
|
||||||
operator: this._conditions[i]['operator'],
|
operator: this._conditions[i]['operator'],
|
||||||
value: this._conditions[i]['value'],
|
value: this._conditions[i]['value'],
|
||||||
|
flags: data['flags'],
|
||||||
required: this._conditions[i]['required']
|
required: this._conditions[i]['required']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -926,7 +927,14 @@ Zotero.Search.prototype._buildQuery = function(){
|
||||||
case 'contains':
|
case 'contains':
|
||||||
case 'doesNotContain': // excluded with NOT IN above
|
case 'doesNotContain': // excluded with NOT IN above
|
||||||
condSQL += ' LIKE ?';
|
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;
|
break;
|
||||||
|
|
||||||
case 'is':
|
case 'is':
|
||||||
|
@ -1120,6 +1128,10 @@ Zotero.SearchConditions = new function(){
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define and set up the available advanced search conditions
|
* Define and set up the available advanced search conditions
|
||||||
|
*
|
||||||
|
* Flags:
|
||||||
|
* - special
|
||||||
|
* - template
|
||||||
*/
|
*/
|
||||||
function _init(){
|
function _init(){
|
||||||
_conditions = [
|
_conditions = [
|
||||||
|
@ -1266,7 +1278,10 @@ Zotero.SearchConditions = new function(){
|
||||||
doesNotContain: true
|
doesNotContain: true
|
||||||
},
|
},
|
||||||
table: 'itemTags',
|
table: 'itemTags',
|
||||||
field: 'tag'
|
field: 'tag',
|
||||||
|
flags: {
|
||||||
|
leftbound: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1356,6 +1371,9 @@ Zotero.SearchConditions = new function(){
|
||||||
},
|
},
|
||||||
table: 'fulltextItemWords',
|
table: 'fulltextItemWords',
|
||||||
field: 'word',
|
field: 'word',
|
||||||
|
flags: {
|
||||||
|
leftbound: true
|
||||||
|
},
|
||||||
special: true
|
special: true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1414,11 +1432,13 @@ Zotero.SearchConditions = new function(){
|
||||||
sortValues[localized] = {
|
sortValues[localized] = {
|
||||||
name: i,
|
name: i,
|
||||||
localized: localized,
|
localized: localized,
|
||||||
operators: _conditions[i]['operators']
|
operators: _conditions[i]['operators'],
|
||||||
|
flags: _conditions[i]['flags']
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alphabetize by localized name
|
// Alphabetize by localized name
|
||||||
|
// TODO: locale collation sort
|
||||||
sortKeys = sortKeys.sort();
|
sortKeys = sortKeys.sort();
|
||||||
for each(var i in sortKeys){
|
for each(var i in sortKeys){
|
||||||
_standardConditions.push(sortValues[i]);
|
_standardConditions.push(sortValues[i]);
|
||||||
|
|
|
@ -38,6 +38,7 @@ pref("extensions.zotero.keys.copySelectedItemsToClipboard", 'C');
|
||||||
// Fulltext indexing
|
// Fulltext indexing
|
||||||
pref("extensions.zotero.fulltext.textMaxLength", 500000);
|
pref("extensions.zotero.fulltext.textMaxLength", 500000);
|
||||||
pref("extensions.zotero.fulltext.pdfMaxPages", 100);
|
pref("extensions.zotero.fulltext.pdfMaxPages", 100);
|
||||||
|
pref("extensions.zotero.search.useLeftBound", true);
|
||||||
|
|
||||||
// Export and citation settings
|
// Export and citation settings
|
||||||
pref("extensions.zotero.export.lastTranslator", '14763d24-8ba0-45df-8f52-b8d1108e7ac9');
|
pref("extensions.zotero.export.lastTranslator", '14763d24-8ba0-45df-8f52-b8d1108e7ac9');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user