search

0 views
Skip to first unread message

Kenneth Gonsalves

unread,
Jun 8, 2009, 12:54:54 AM6/8/09
to fosscon...@googlegroups.com
hi,

there is a request for search for the site. How do we do this?
--
regards
kg
http://lawgon.livejournal.com

Thejaswi Puthraya

unread,
Jun 8, 2009, 1:51:18 AM6/8/09
to fossconf-devel
Hi,
On Jun 8, 9:54 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> hi,
>
> there is a request for search for the site. How do we do this?

Check haystack search [1] for django. It seems to be quite easy to
learn
and deploy.

I can only work on this in the evening. Have been sneeking into
google
groups and gmail through a proxy. Can't do it too frequently for the
fear
of detection.

Or the other temporary solution would be to put google custom coop
search. I am personally -1 against this.

[1] http://haystacksearch.org/

--
Cheers
Theju

Kenneth Gonsalves

unread,
Jun 8, 2009, 2:16:08 AM6/8/09
to fosscon...@googlegroups.com
On Monday 08 June 2009 11:21:18 Thejaswi Puthraya wrote:
> Hi,
>
> On Jun 8, 9:54 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> > hi,
> >
> > there is a request for search for the site. How do we do this?
>
> Check haystack search [1] for django. It seems to be quite easy to
> learn
> and deploy.
>
> I can only work on this in the evening.

I understand that - I do not expect your replies until evening/next morning.

Thejaswi Puthraya

unread,
Jun 14, 2009, 12:50:59 AM6/14/09
to fossconf-devel
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>&nbsp;</
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

Thejaswi Puthraya

unread,
Jun 14, 2009, 12:56:29 AM6/14/09
to fossconf-devel


On Jun 14, 9:50 am, Thejaswi Puthraya <thejaswi.puthr...@gmail.com>
Just created an issue on [1] with the diff.

[1] http://bitbucket.org/lawgon/fossconf/issue/12/add-search-to-site

--
Cheers
Theju
Reply all
Reply to author
Forward
0 new messages