'bootstrap_pagination',
'googletools',
'registration',
+ 'haystack',
)
TEMPLATE_CONTEXT_PROCESSORS = (
# },
# },
# }
+
+
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
+ 'URL': 'http://127.0.0.1:9200/',
+ 'INDEX_NAME': 'haystack',
+ },
+}
+
--- /dev/null
+from haystack import indexes
+from telemeta.models import *
+
+
+class MediaItemIndex(indexes.SearchIndex, indexes.Indexable):
+
+ title = indexes.CharField(use_template=True, document=True)
+
+ def get_model(self):
+ return MediaItem
--- /dev/null
+{% extends 'telemeta/base.html' %}
+
+{% block content %}
+ <h2>Search</h2>
+
+ <form method="get" action=".">
+ <table>
+ {{ form.as_table }}
+ <tr>
+ <td> </td>
+ <td>
+ <input type="submit" value="Search">
+ </td>
+ </tr>
+ </table>
+
+ {% if query %}
+ <h3>Results</h3>
+
+ {% for result in page.object_list %}
+ <p>
+ <a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
+ </p>
+ {% empty %}
+ <p>No results found.</p>
+ {% endfor %}
+
+ {% if page.has_previous or page.has_next %}
+ <div>
+ {% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Previous{% if page.has_previous %}</a>{% endif %}
+ |
+ {% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Next »{% if page.has_next %}</a>{% endif %}
+ </div>
+ {% endif %}
+ {% else %}
+ {# Show some example queries to run, maybe query syntax, something else? #}
+ {% endif %}
+ </form>
+{% endblock %}
\ No newline at end of file
url(r'^search/(?P<type>[A-Za-z0-9._-]+)/$', SearchView.as_view(), name="telemeta-search-type"),
url(r'^search_criteria/$', home_view.edit_search, name="telemeta-search-criteria"),
url(r'^complete_location/$', home_view.complete_location, name="telemeta-complete-location"),
+ url(r'^search_haystack/', include('haystack.urls')),
# administration
url(r'^admin/$', admin_view.admin_index, name="telemeta-admin"),