Go to page content

Tweaking Zotonic Search

Workaround for pages not showing up in Zotonic's search.

Why

Sometimes the stop-words PostgreSQL comes with are too restrictive and prevent you from finding pages in Zotonic. This guide provides a way to tune this to get around that limitation.

Assumptions

Readers are assumed to be comfortable using the command-line and editing files from command-line editors.

How

Zotonic uses PostgreSQL full text search in the admin area for adding connections, adding menu items and searching for pages.

You can also use full text search in your pages using the Fulltext Search Model:

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

In order to make the search more relevant, PostgreSQL uses a dictionary of stopwords to specify words that will be ignored.

My site is in English, and I am having some trouble adding my "About" page to my site menu, so I search for the file called english.stop:

locate english.stop

open it in a text editor:

vim /path/to/english.stop

On opening it notice that the word "about" is in there. Delete this word then save and close the file.

Now get PostgreSQL to reload its configuration (including the English stop words):

sudo /etc/init.d/postgresql reload

Troubleshooting

There are no troubleshooting steps available for this guide.  Please provide any you have learned in the comments below or on the Zotonic Users Group.

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