diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-19 22:19:03 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-19 22:19:03 +0100 |
commit | 6e6275231e6e66f9024d10c5395479e86939eb20 (patch) | |
tree | 84b9bf7ddb85f276d8b8596269bd9b5e9e0b3c54 | |
parent | c22d66b350db2e213cc916fae4f6207440a9be4f (diff) |
Only index fields that should be indexed for free / field search
-rw-r--r-- | lesana/collection.py | 15 | ||||
-rw-r--r-- | tests/test_collection.py | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/lesana/collection.py b/lesana/collection.py index 305fed3..df4a65e 100644 --- a/lesana/collection.py +++ b/lesana/collection.py @@ -23,13 +23,14 @@ class Entry(object): def indexed_fields(self): fields = [] for field in self.collection.settings['fields']: - prefix = field.get('prefix', 'X'+field['name'].upper()) - fields.append({ - 'value': self.data.get(field['name']), - 'prefix': prefix, - 'name': field['name'], - 'free_search': True, - }) + if field['index'] in ['free', 'field']: + prefix = field.get('prefix', 'X'+field['name'].upper()) + fields.append({ + 'value': self.data.get(field['name']), + 'prefix': prefix, + 'name': field['name'], + 'free_search': field['index'] == 'free', + }) return fields diff --git a/tests/test_collection.py b/tests/test_collection.py index 1bacfd6..82722b1 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -59,14 +59,14 @@ class testEntries(unittest.TestCase): data = ruamel.yaml.load(fp) entry = lesana.Entry(self.collection, data=data, fname=fname) self.assertEqual(entry.idterm, 'Q'+data['uid']) - self.assertEqual(len(entry.indexed_fields), 4) + self.assertEqual(len(entry.indexed_fields), 2) fname = '11189ee47ddf4796b718a483b379f976.yaml' uid = '11189ee47ddf4796b718a483b379f976' with open(os.path.join(self.basepath, fname)) as fp: data = ruamel.yaml.load(fp) entry = lesana.Entry(self.collection, data=data, fname=fname) self.assertEqual(entry.idterm, 'Q'+uid) - self.assertEqual(len(entry.indexed_fields), 3) + self.assertEqual(len(entry.indexed_fields), 2) def test_write_new(self): new_entry = lesana.Entry(self.collection) |