Hi,
I have basic search for site ready using haystack and whoosh.
Somehow,
I have not been so impressed with whoosh's indexing (didn't try out
solr,
which is the recommended indexing engine). The best part about whoosh
is that it is very easily installable.
Here is the diff for the site. Please apply it against lawgon's latest
tree:
diff -r 9632dff72473 templates/search/indexes/web/delegate_text.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/search/indexes/web/delegate_text.txt Sun Jun 14
10:09:49 2009 +0530
@@ -0,0 +1,1
@@
+
{{ object.title }}
diff -r 9632dff72473 templates/search/
search.html
--- /dev/null Thu Jan 01 00:00:00 1970
+0000
+++ b/templates/search/search.html Sun Jun 14 10:09:49 2009
+0530
@@ -0,0 +1,27
@@
+{% extends "base.html"
%}
+
+{% block centercontent
%}
+<h2>Search</
h2>
+
+<form method="get"
action=".">
+
<table>
+
{{ form.as_table }}
+
<tr>
+ <td> </
td>
+
<td>
+ <input type="submit"
value="Search">
+ </
td>
+ </
tr>
+ </
table>
+
+ {% if page.object_list
%}
+ {% for result in page.object_list
%}
+
<p>
+
{{ result.object }}
+ </
p>
+ {% endfor
%}
+ {% else
%}
+ <p>No results found.</
p>
+ {% endif
%}
+</
form>
+{% endblock
%}
diff -r 9632dff72473
urls.py
--- a/urls.py Sat Jun 13 05:48:45 2009
+0530
+++ b/urls.py Sun Jun 14 10:09:49 2009
+0530
@@ -3,6 +3,9
@@
from django.contrib.auth.decorators import login_required,
user_passes_test
from django.contrib import
admin
import
os
+import
haystack
+
+haystack.autodiscover
()
admin.autodiscover
()
@@ -28,6 +31,6 @@
# Added for quick deployment. Don't use this in production.
#url(r'^sitemedia/(?P<path>.*)$','django.views.static.serve',
{'document_root':
#
os.path.join(os.getcwd(),'sitemedia')}),
-
+ url(r'^search/', include('haystack.urls')),
)
diff -r 9632dff72473 web/search_indexes.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/search_indexes.py Sun Jun 14 10:09:49 2009 +0530
@@ -0,0 +1,20 @@
+import datetime
+from haystack import indexes
+from haystack.sites import site
+from web.models import Delegate, Occupation
+
+
+class DelegateIndex(indexes.SearchIndex):
+ text = indexes.CharField(document=True, use_template=True)
+ delegate = indexes.CharField(model_attr='username')
+ resume = indexes.CharField(model_attr='reume')
+ city = indexes.CharField(model_attr='city')
+ occupation = indexes.CharField(model_attr='occupation')
+
+site.register(Delegate, DelegateIndex)
Currently, it indexes only the Delegate model. We could add
indexes for Talks, Schedules quite easily on similar lines.
Just another note, it requires a manage.py to recreate, add
indexes. So please, add the file back to the repository.
--
Cheers
Theju