diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2011-07-09 20:43:09 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2011-07-09 20:46:39 (GMT) |
commit | cd6f7a5136cad53ea1612c2871c0fc2b23ecce51 (patch) | |
tree | 9d3683f0d57c86becb8d6701e9877b03d2fd5c84 | |
parent | 8bce5a16618b45d519d322da77e93b663e0c8c55 (diff) |
Fix indexing of non-string (e.g. numeric) property values as terms
-rw-r--r-- | gdatastore/index.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gdatastore/index.py b/gdatastore/index.py index 4b0569a..177a300 100644 --- a/gdatastore/index.py +++ b/gdatastore/index.py @@ -87,7 +87,8 @@ class TermGenerator(xapian.TermGenerator): if name not in properties: continue - self._index_property(properties.pop(name), info['prefix']) + value = info['type'](properties.pop(name)) + self._index_property(value, info['prefix']) def _index_unknown(self, properties): """ @@ -99,18 +100,19 @@ class TermGenerator(xapian.TermGenerator): if name in _IGNORE_PROPERTIES or name in _STANDARD_VALUES: continue - if isinstance(value, unicode): - value = value.encode('utf-8') - elif not isinstance(value, str): - value = str(value) - self._index_property(_prefix_for_unknown(name), value) def _index_property(self, value, prefix): + if isinstance(value, unicode): + value = value.encode('utf-8') + elif not isinstance(value, str): + value = str(value) + # We need to add the full value (i.e. not split into words), too, so # we can enumerate unique values. It also simplifies setting up # dictionary-based queries. self._document.add_term(_PREFIX_FULL_VALUE + prefix + value) + self.index_text(value, 1, prefix) self.increase_termpos() |