Is there a way to sort the query below by the number of search items found
in each result?
def GET(*args,**vars):
search = [x for x in request.vars['search'].split(' ') if len(x) >
3]
result = []
if search:
query = db.question.heading.contains(search, all=False) |
db.question.content.contains(search, all=False) |
db.tag.tag.contains(search)
result = db(query).select(db.question.ALL,
join=[db.question.on(db.question.id==db.question_tag.question_id),
db.question_tag.on(db.question_tag.tag_id==db.tag.id)])
return response.json(result)
Basically I want to find the most relevant result, assuming the result that
matches the most results is most relevant.
Cheers!
--
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.