I now understand something about text searches in Jam.py :)
The search-input on the view form matches in CONTAINS_ALL mode, which splits the search string up into words using space delimiters.
Using a Filter form input set to CONTAINS mode does not split the string, and so can be used to search for a phrase. However, if I wanted to search for multiple phrases, I would need multiple Filter form inputs for the same field. This works fine, but I thought there might be a simpler way.
I made some small changes to the Jam.py source code to alter the behaviour of the CONTAINS_ALL match, so that it handles words and phrases through a single input. Now if I enter a search string like: thank you "very much" for "asking me" it finds records with the words thank, you, for, and the phrases very much, asking me, which is the behaviour I want.
If anyone is interested, here are the changes (shown in red):
To jam.py - change behaviour of CONTAINS_ALL:
import shlex
def where_clause(self, query, db_module=None):
if db_module is None:
db_module = self.task.db_module
conditions = []
filters = query['__filters']
deleted_in_filters = False
if filters:
for field_name, filter_type, value in filters:
if not value is None:
field = self._field_by_name(field_name)
if field_name == self._deleted_flag:
deleted_in_filters = True
if filter_type == consts.FILTER_CONTAINS_ALL:
try:
values = shlex.split(value
except:
values = value.split()
for val in values:
conditions.append(self._get_condition(field, consts.FILTER_CONTAINS, val, db_module))
To jam.js - change field text highlighting to match:
function highlight(text, search) {
var i = 0,
result = text,
substr,
start,
str,
strings,
pos,
p = [];
if (search) {
text += '';
//strings = search.toUpperCase().split(' ')
var regexp = /[^\s"]+|"([^"]*)"/gi;
var strings = [];
var cap_srch = search.toUpperCase();
do {
var match = regexp.exec(cap_srch);
if (match != null)
{
strings.push(match[1] ? match[1] : match[0]);
}
} while (match != null);