Yeah, I don't think you'd want to do this in python anyway, it's more 
efficient to let the server handle that, as it has optimizations that we 
can't use.

On Tuesday, January 6, 2015 3:47:41 PM UTC-7, Massimo Di Pierro wrote:
>
> No. :-(
>
> On Tuesday, 6 January 2015 12:23:49 UTC-6, Ruud Schroen wrote:
>>
>> Hi all,
>>
>> I have this raw sql which I execute:
>>
>> val = "what the user enters in the searchbar"
>> sql_statement = """
>>                 SELECT pid, title, description, created_on, slug
>>                 FROM (SELECT infobank_article.id as pid,
>>                              infobank_article.title as title,
>>                              infobank_article.description as description,
>>                              infobank_article.created_on as created_on,
>>                              infobank_article.slug as slug,
>>                              setweight(to_tsvector('dutch', 
>> infobank_article.title), 'A') ||
>>                              setweight(to_tsvector('dutch', 
>> infobank_article.body_text), 'B') ||
>>                              setweight(to_tsvector('simple', 
>> coalesce(string_agg(plugin_tagging_tag.name, ' '))), 'B') as document
>>                       FROM infobank_article
>>                       JOIN plugin_tagging_link ON 
>> plugin_tagging_link.record_id = infobank_article.id
>>                       JOIN plugin_tagging_tag ON plugin_tagging_tag.id = 
>> plugin_tagging_link.tag
>>                       GROUP BY infobank_article.id) p_search
>>                 WHERE p_search.document @@ to_tsquery('%s')
>>                 ORDER BY ts_rank(p_search.document, to_tsquery('%s'))
>>                 DESC
>>                 LIMIT 10 OFFSET 0;
>>                 """ % (val, val)
>> articles = executesql(sql_statement)
>>
>>  
>> It takes articles from the db and orders them by relevance (search 
>> engine).
>> It works, but I was wondering if there is a web2py query to do this?
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to