diff options
-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) |