Project 6: search that finds the right things
Visitors judge a site by whether its search finds what they look for. In this project you learn how the built-in search engine indexes content, decide which fields should be found, change one, rebuild the index and prove the difference.
Contents
At a glance
| Level | Intermediate |
| Time | About 2 hours |
| Paths | Administrator, developer |
| Prerequisites | project 1; a terminal; a study site that only you use, because classes are shared by everyone on an installation |
Goal
A search test plan of ten queries with expected results, one changed Searchable flag, a rebuilt index, and a before and after comparison that matches your expectations.
Before you start
- Read Searching for the editor's view.
- The installation's search engine is set in
settings/site.ini [SearchSettings] SearchEngine; the shipped value iseZSearchEngine, the built-in engine. It needs no extra server: its index lives in two tables of the site's own database (Lesson 1.2: The built-in search engine). - The engine indexes only attributes marked Searchable in their class; a changed flag applies to new indexing, so existing objects keep their old entries until they are republished or the index is rebuilt (Lesson 2.4: Choosing searchable attributes).
Check the engine on your site:
php bin/php/console exp:ini where site/SearchSettings/SearchEngine siteTasks
Write the test plan. Ten queries for your club site: words from titles, from summaries, from rich text, a phrase in double quotes, a word with an accent, and a word that should not be found (for example from an internal field). For each, write the items you expect.
Run it before. Use the quick search and the advanced search (class and class attribute). Record the results.
Read the flags. In Setup > Classes, open your class from project 1. Note which attributes say Is searchable.
Change one flag. Add an internal attribute such as "Notes for organizers" (Text block) if you have none, fill it in one event with a unique word, and make it not searchable. Press OK at the end, not leaving the class in edit.
Rebuild the index. As the trainers' lesson shows:
php bin/php/updatesearchindex.php --clean -s <siteaccess> --allow-root-user--cleanfirst empties the whole index, so search finds less and less until the run is complete; without it, the old entries stay findable while each object is replaced (Lesson 2.3: Rebuilding the search index). Leave out--allow-root-userwhen you are notroot.Run it after. Repeat the ten queries and record the results.
Explain the differences. For each query whose result changed or did not match your expectation, write why.
Hand in
- The test plan with expected and actual results, before and after.
- The output lines of the rebuild (the number of objects to index).
- A screenshot of the class with the changed flag.
- A short report: which attributes should be searchable on your site and why.
Rubric
Score the four common criteria of Grading your own work, and these checks (7):
- Ten queries with expected results written before testing.
- The engine in use was shown with
exp:ini where. - One flag was changed on a class the learner owns, on their own installation.
- The index was rebuilt, and the report says what
--cleandoes. - The hidden word is no longer found after the rebuild.
- The report explains a phrase search and an accent search.
- Every unexpected result has an explanation or an open question.
Stretch goals
- Read about delayed indexing and the
indexcontentcronjob (Lesson 2.2). - Compare the built-in engine with Solr and the
ezfindextension at a glance (Lesson: Solr and ezfind at a glance). Solr is a separate search server; it is not needed for this project. - Search the help itself and compare how it ranks pages (Searching).
Related pages
- Study projects: overview
- Searching
- The trainers' Search course
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.