Search syntax

With the Contao search engine, you can find more than just words. The search syntax supports the AND/OR search as well as the phrase search and the use of wildcards.

This feature is by no means specific to Contao. Google and other search engines also support searching for phrases or forcing or excluding search terms. Most of the major search engines offer even more options, for example, searching for specific file types, languages or time periods.

AND/OR search

Let’s assume a simple search for “web design” will return five hits.

By default, Contao only searches for pages that contain all search terms (AND search). If you select the “Find any word” option, pages that contain only one of the two words will be returned (OR search). This increases the number of hits to seven in our example.

Phrase search

Phrase searches are not just looking for single words, but for word combinations that are in a certain order. To search for a phrase, you just have to put the corresponding words in quotation marks. The search for “web design” only returns three hits compared to the AND/OR search, namely the pages that actually contain the term “web design”.

Search with wildcards

Maybe you are not only interested in web design, but also in all kinds of other things related to the web, such as web hosting. That’s why you want to find everything that starts with the word “web”. This is exactly what Contao offers the wildcard search.

Start a new search, and enter “web*” in the search input field. The asterisk acts as a wildcard and stands for any other character(s). As you will see, this search will return significantly more results than the previous two. It now includes results that contain expressions like “web application”, “web hosting” or “web technology”.

Force search terms

Enforcing search terms is a good way to further refine OR searches. Let’s say you want to find all pages that contain the terms “web”, “hosting” or “design” but you are only interested in design related to the web. The design of industrial products is not relevant for you and should therefore not appear in the results.

Surely you immediately realized that you can achieve this with two AND searches for “web design” and “web hosting”. However, this solution is quite uncomfortable, as the two hit lists must be searched separately and cannot be sorted by a common relevance.

A better option is to search for “+web hosting design”, which means: “Search for the words ‘hosting’ and ‘design’, but only on pages where the word web occurs”. From the plus sign, Contao recognizes that a search term must be included in any case. Note that there must be no space between the plus sign and the search term.

Exclude search term

Excluding a search term is the counterpart to forcing a search term and has the effect that only those pages are found which do not contain a certain term. In the example above, you have reduced the number of results from eight to five by using the enforcing word “Web”. If you now exclude the word “Web”, you will find exactly the three missing pages.

Start a last search and enter “-web hosting design” in the search field. The minus sign tells Contao that a search term must never appear on the page. Note that there must not be any space between the minus sign and the search term.