Go to page content

m_search

Search pages in all kinds of ways.

The m_search model provides access to queries for searching pages.

Most searches are implemented in the mod_search module, though any module can implement a search by observing the 'search_query' notification.

Example, fetching the latest 10 modified pages in the “text” category:

{% for id in m.search[{latest cat="text" pagelen=10}] %}
  {{ m.rsc[id].title }}
{% endfor %}

Another example, searching for a text and requesting the second page with 20 results at a time:

{% for id, rank in m.search.paged[{fulltext text=query_string page=2 pagelen=20}] %}
   {{ m.rsc[id].title }}
{% endfor %}

See also the {% pager %} scomp.

The following searches are available by mod_search and the base Zotonic install:

NameDescriptionRequired arguments
featuredList of pages, featured ones first.
featuredList of pages in a category, featured ones first.cat
featuredList of pages in a category having a certain object, featured pages first.cat, object, predicate
latestThe newest pages.
latestThe newest pages within in a category.cat
upcomingPages with future date_end, sorted on ascending date_start.cat
autocompleteFull text search where the last word gets a wildcard.text
autocompleteFull text search where the last word gets a wildcard, filtered by category.cat, text
fulltextFull text search. Returns {id,score} tuples.text
fulltextFull text search, filtered by category. Returns {id,score} tuples.cat, text
referrersAll subjects of a page.id
media_category_imageAll pages with a medium and within a certain category. Used to find category images.cat
media_category_depictionAll pages with a depiction edge to an image. Used to find category images.cat
mediaAll pages with a medium, ordered by descending creation date.
all_bytitleReturn all {id,title} pairs for a category, sorted on title.cat
all_bytitle_featuredReturn all {id,title} pairs for a category, sorted on title, featured pages firstcat
all_bytitleReturn all {id,title} pairs for a category without subcategories, sorted on title.cat_is
all_bytitle_featuredReturn all {id,title} pairs for a category without subcategories, sorted on title, featured pages first.cat_is
match_objectsReturns a list of pages with similar object ids to the objects of the given rsc with id id.  Returns {id, rank}. Accepts optional cat parameters for filtering on category.id
match_objects_catsReturns a list of pages with similar object ids or categories.  Returns {id, rank}. Accepts optional cat parameters for filtering on category.

id

query

Very powerful search with which you can implement almost all of the other search functionality.

The documentation page of m.search[{query}]


archive_year
Returns an overview on publication year basis, for a specified category. Every row returned has parts: "as_date", "year" and "count". The order is descending, newest year first. (since 0.7)
cat
archive_year_monthReturn a grouped "archive" overview of resources within a category. The result is a double list, consisting of [ {year, [ months ] }]. The result is grouped on publication year and month, and includes counts. The order is descending, newest year first.cat
keyword_cloudReturn a list of (keyword_id, count) for all resources within a given category. The list is ordered on keyword title.cat
previousGiven an id, return a list of "previous" ids in the given category. This list is ordered by publication date, latest first.id, cat
nextGiven an id, return a list of "next" ids in the given category. This list is ordred by publication date, oldest first.id, cat

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.