Hi,
Sorry I took so long before reacting, we are currently ramping up for
1.0 release of elasticsearch.
I have spent some time poking around Haystack internals and I'd like
to discuss some changes we could make to make things a little simpler
for the backends moving forwards. Most specifically this leads with
the separation of SearchQuery and Backend.
I'd like to propose to remove the SearchQuery from the individual
backends - just use the BaseSearchQuery (renaming it to SearchQuery)
and move all backend-specific stuff to the Backend class itself. That
can be greatly simplified in terms of interface where it could then
just accept SearchQuery in a lot of it's APIs, thus eliminating need
for stuff like
https://github.com/toastdriven/django-haystack/blob/master/haystack/backends/elasticsearch_backend.py#L864-L900
The freeing up of the interface of the Engine would also mean that for
elasticsearch we could finally move away from using the lucene query
syntax and to more structured queries that will be able to optimize
better (maybe even used cached filters in some cases) and generally
produce better results - for example a match query on a field will use
the field's analyzer so users can potentially have different analyzers
per field (multi lingual, special analyzers for stuff like url paths
etc).
Another benefit this should bring would be the ability to create
completely custom queries and having them still wrapped in haystack
queryset mechanism. So something like .raw() functionality. This would
simple produce an instance of SearchQuery in the queryset that will
have .raw attribute/method/whatever that the backend will pick up and
know not to do any other modifications to the query on top of doing
pagination and serializing the results.
This will be a backwards incompatible change for people with their own
backends but I do believe it's worth it.
What do you think?
Thanks!
Honza Král
E-Mail:
honza...@gmail.com
Phone:
+420 606 678585