maybe i misunderstood your  question, but maybe it will help

On Fri, Oct 1, 2010 at 8:19 PM, m1chael <myk...@gmail.com> wrote:
> Hello!
>
> I use PostgreSQL, and this is how I accomplished a full text search:
>
> def search(request):
>  # how to set up postgresql for full text searching
>  #alter table quote_quote add column body_tsv tsvector;
>  #CREATE TRIGGER quote_quote_tsvectorupdate BEFORE INSERT OR UPDATE
> ON quote_quote FOR EACH ROW EXECUTE PROCEDURE
> tsvector_update_trigger(quote_tsv, 'pg_catalog.english', quote);
>  #CREATE INDEX quote_quote_tsv ON quote_quote USING gin(quote_tsv);
>  #UPDATE quote_quote SET quote_tsv=to_tsvector(quote);
>
>  q = request.GET['q']
>
>  quotes = Quote.objects.extra(
>    select={
>        'snippet': "ts_headline(quote, plainto_tsquery(%s))",
>        'rank': "ts_rank_cd(quote_tsv, plainto_tsquery(%s), 32)",
>    },
>    where=["quote_tsv @@ plainto_tsquery(%s)"],
>    params=[q],
>    select_params=[q, q],
>    order_by=('-rank',)
>  )
>
>  paginator = Paginator(quotes, 50)
>
>  try:
>    page = int(request.GET.get('page', '1'))
>  except ValueError:
>    page = 1
>
>  try:
>    quotes = paginator.page(page)
>  except (EmptyPage, InvalidPage):
>    quotes = paginator.page(paginator.num_pages)
>
>  my_data_dictionary = {
>        'quotes': quotes,
>        'q' : q,
>  }
>
>  return render_to_response('results.html',
>                               my_data_dictionary,
>                               context_instance=RequestContext(request))
>
> urlpatterns = patterns('',
>    url(r'^search/$', search),
> )
>
> On Fri, Oct 1, 2010 at 7:26 PM, Andrej <amas...@gmail.com> wrote:
>> Check this out:
>>
>> http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/
>>
>> On Oct 1, 6:52 am, Alessandro Ronchi <alessandro.ron...@soasi.com>
>> wrote:
>>> On Fri, Oct 1, 2010 at 3:35 AM, Steve Holden <holden...@gmail.com> wrote:
>>> > On 9/30/2010 8:26 PM, Nick Arnett wrote:
>>> > > Brain is mush, though.
>>>
>  >> Thank you. I'm waiting with hope :)
>>>
>>> --
>>> Alessandro Ronchihttp://www.soasi.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to