Hi all,
I have this raw sql which I execute in my query:
sql_statement = """
> SELECT id, title, description, created_on, slug
> FROM (SELECT infobank_article.id as id,
> 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 = db.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.