diff options
-rw-r--r-- | TODO.rst | 6 | ||||
-rw-r--r-- | lesana/collection.py | 4 | ||||
-rw-r--r-- | tests/data/complex/items/d4f361b0e3e541508eaf82c04451797f.yaml | 7 | ||||
-rw-r--r-- | tests/data/complex/settings.yaml | 4 | ||||
-rw-r--r-- | tests/test_collection.py | 4 |
5 files changed, 22 insertions, 3 deletions
@@ -6,3 +6,9 @@ The following features are already planned. lesana). * Write a command which reads data from a collection and writes it to another one, using a simple mapping of fields. + +The following features may be nice to have. + +* Having an indexing mode that adds the field as a value instead of a + term, see + https://getting-started-with-xapian.readthedocs.io/en/latest/concepts/indexing/values.html diff --git a/lesana/collection.py b/lesana/collection.py index fbdb935..6c86436 100644 --- a/lesana/collection.py +++ b/lesana/collection.py @@ -165,7 +165,7 @@ class Collection(object): for v in values: try: self.indexer.index_text( - v, + str(v), 1, field['prefix']) except ValueError as e: @@ -179,6 +179,8 @@ class Collection(object): values = entry.data.get(field['name']) else: values = [entry.data.get(field['name'])] + if not values: + values = [] for v in values: try: self.indexer.index_text(v) diff --git a/tests/data/complex/items/d4f361b0e3e541508eaf82c04451797f.yaml b/tests/data/complex/items/d4f361b0e3e541508eaf82c04451797f.yaml new file mode 100644 index 0000000..2331e69 --- /dev/null +++ b/tests/data/complex/items/d4f361b0e3e541508eaf82c04451797f.yaml @@ -0,0 +1,7 @@ +name: 'Empty lists' +description: | + This entry has no tags and no keywords +position: '' +something: +tags: +keywords: diff --git a/tests/data/complex/settings.yaml b/tests/data/complex/settings.yaml index bd2179c..612591f 100644 --- a/tests/data/complex/settings.yaml +++ b/tests/data/complex/settings.yaml @@ -19,3 +19,7 @@ fields: type: list list: string index: field + - name: keywords + type: list + list: string + index: free diff --git a/tests/test_collection.py b/tests/test_collection.py index 84f0a7a..2b1864a 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -241,9 +241,9 @@ class testComplexCollection(unittest.TestCase): self.collection.settings['name'], "Fully featured lesana collection" ) - self.assertEqual(len(self.collection.settings['fields']), 5) + self.assertEqual(len(self.collection.settings['fields']), 6) self.assertIsNotNone(self.collection.stemmer) - self.assertEqual(len(self.collection.indexed_fields), 4) + self.assertEqual(len(self.collection.indexed_fields), 5) def test_index(self): self.collection.update_cache() |