I am finally taking the time to write about optimizing the Solr schema file. In my last post I showed that eZ Find already ships with a default search field called
ezf_df_text. The downside of searching one field is that field needs to be controlled, and the only way it can be controlled is by manually editing the Solr schema file. As you might expect, eZ Find does not control this file very well out of the box.
<copyField source="*_lk" dest="ezf_df_text"/> <copyField source="*_k" dest="ezf_df_text"/> <copyField source="*_t" dest="ezf_df_text"/> <copyField source="*_s" dest="ezf_df_text"/>
A copyField will take any field you tell it to and copy it into another field. The code above is what ships with eZ Find, every single
*_t (text), and
*_s (string) is added to the
ezf_df_text field. For obvious reasons the average installation probably doesn’t need every piece of content searchable. The first step is to delete the default copyFields (e.g. your site users probably shouldn’t be searched by default).
Luckily, there is only one other step! Unfortunately, this one step can be very time consuming. Visit the
luke output for your Solr install and make a list of all the fields you need to search. Make a copyField for every field you want to search, adding each field to the
Remember, this can offer major speed improvements in your searches, especially if you are managing a large amount of content. There are still other optimizations (stored/not stored, indexed/not indexed, term vectors, etc), but that is for another time.
Finally, I did submit a pull request to the eZ Find project. It adds a new search parameter allowing users to declare custom search fields. https://github.com/ezsystems/ezfind/pull/93