Comments (3)
int and float can't be used interchangeably due to the way floats are serialised by Xapian and ints are zero padded strings.
Instead, it is necessary to only use float values for float fields, eg.: 32.0 instead of 32.
from xapian-haystack.
When I try to give it a float value I get a TypeError
>>> sqs.filter(lat__gte=34.0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/somebody//<ipython console> in <module>()
/var/lib/python-support/python2.5/IPython/Prompts.py in __call__(self, arg)
549
550 # and now call a possibly user-defined print mechanism
--> 551 manipulated_val = self.display(arg)
552
553 # user display hooks can change the variable to be stored in
/var/lib/python-support/python2.5/IPython/Prompts.py in _display(self, arg)
575 return IPython.generics.result_display(arg)
576 except TryNext:
--> 577 return self.shell.hooks.result_display(arg)
578
579 # Assign the default display method:
/var/lib/python-support/python2.5/IPython/hooks.py in __call__(self, *args, **kw)
139 #print "prio",prio,"cmd",cmd #dbg
140 try:
--> 141 ret = cmd(*args, **kw)
142 return ret
143 except ipapi.TryNext, exc:
/var/lib/python-support/python2.5/IPython/hooks.py in result_display(self, arg)
169
170 if self.rc.pprint:
--> 171 out = pformat(arg)
172 if '\n' in out:
173 # So that multi-line strings line up with the left column of
/usr/lib/python2.5/pprint.pyc in pformat(self, object)
109 def pformat(self, object):
110 sio = _StringIO()
--> 111 self._format(object, sio, 0, 0, {}, 0)
112 return sio.getvalue()
113
/usr/lib/python2.5/pprint.pyc in _format(self, object, stream, indent, allowance, context, level)
127 self._readable = False
128 return
--> 129 rep = self._repr(object, context, level - 1)
130 typ = _type(object)
131 sepLines = _len(rep) > (self._width - 1 - indent - allowance)
/usr/lib/python2.5/pprint.pyc in _repr(self, object, context, level)
193 def _repr(self, object, context, level):
194 repr, readable, recursive = self.format(object, context.copy(),
--> 195 self._depth, level)
196 if not readable:
197 self._readable = False
/usr/lib/python2.5/pprint.pyc in format(self, object, context, maxlevels, level)
205 and whether the object represents a recursive construct.
206 """
--> 207 return _safe_repr(object, context, maxlevels, level)
208
209
/usr/lib/python2.5/pprint.pyc in _safe_repr(object, context, maxlevels, level)
290 return format % _commajoin(components), readable, recursive
291
--> 292 rep = repr(object)
293 return rep, (rep and not rep.startswith('<')), False
294
/home/somebody//apps/external/haystack/query.pyc in __repr__(self)
37
38 def __repr__(self):
---> 39 data = list(self[:REPR_OUTPUT_SIZE])
40
41 if len(data) > REPR_OUTPUT_SIZE:
/home/somebody//apps/external/haystack/query.pyc in __getitem__(self, k)
154
155 if self._result_cache is not None:
--> 156 if not self._cache_is_full():
157 # We need check to see if we need to populate more of the cache.
158 if isinstance(k, slice):
/home/somebody//apps/external/haystack/query.pyc in _cache_is_full(self)
57 def _cache_is_full(self):
58 # Use ">=" because it's possible that search results have disappeared.
---> 59 return len(self._result_cache) >= len(self) - self._ignored_result_count
60
61 def _manual_iter(self):
/home/somebody//apps/external/haystack/query.pyc in __len__(self)
46 def __len__(self):
47 # This needs to return the actual number of hits, not what's in the cache.
---> 48 return self.query.get_count()
49
50 def __iter__(self):
/home/somebody//apps/external/haystack/backends/__init__.pyc in get_count(self)
282 self.run_mlt()
283 else:
--> 284 self.run()
285
286 return self._hit_count
/home/somebody//apps/external/haystack/backends/xapian_backend.pyc in run(self)
998 kwargs['boost'] = self.boost
999
-> 1000 results = self.backend.search(final_query, **kwargs)
1001 self._results = results.get('results', [])
1002 self._hit_count = results.get('hits', 0)
/home/somebody//apps/external/haystack/backends/xapian_backend.pyc in search(self, query_string, sort_by, start_offset, end_offset, fields, highlight, facets, date_facets, query_facets, narrow_queries, boost, **kwargs)
325 database = self._database()
326 query, spelling_suggestion = self._query(
--> 327 database, query_string, narrow_queries, boost
328 )
329 enquire = self._enquire(database, query)
/home/somebody//apps/external/haystack/backends/xapian_backend.pyc in _query(self, database, query_string, narrow_queries, boost)
732 vrp = XHValueRangeProcessor(self)
733 qp.add_valuerangeprocessor(vrp)
--> 734 query = qp.parse_query(query_string, self._flags(query_string))
735 if getattr(settings, 'HAYSTACK_INCLUDE_SPELLING', False) is True:
736 spelling_suggestion = qp.get_corrected_query_string()
TypeError: : Swig director type mismatch in output value of type '(Xapian::valueno, std::string, std::string)'
from xapian-haystack.
Well, this is embarassing. The reason it wasn't working with floats, is that they weren't indexed as floats in the build_schema
method. In fact, they were being indexed as text. I've corrected this in SHA d593924. It works now using sqs.filter(lat_gt=32)
now. No need for the extra .0 bit on the end.
from xapian-haystack.
Related Issues (20)
- No result with django_ct filter.
- Release a version compatible with haystack >= 2.5.1 HOT 5
- django-haystack 1.4 HOT 5
- Facetting with facet value containing a slash returns wrong facet counts
- Multiprocess indexing, locking exceptions HOT 3
- install xapian error HOT 3
- No result when app_lable in uppercase HOT 1
- Travis config testing incompatible django / django-haystack
- When trying to install sphinx wih pip or apt for Xapian Haystack, sphinx.main() can't be called. HOT 1
- Indexing signal processor not working correctly in Xapian Haystack (?) HOT 1
- Latest release on pypi.org not reflected in release on github HOT 16
- pypi sdist tarballs don't include tests HOT 3
- How to integrate with a word segmentator system?
- xapian_wheel_builder wheel setup should include more information HOT 1
- Github Actions - coveralls integration needs more work HOT 3
- Github Actions - expand test matrix, unify coverage reports
- 3.0.1 test_highlight fails HOT 9
- Omitting * from end of range doesn't search correctly.
- Database maintenance: compacting
- Error rebuilding index
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xapian-haystack.