This document discusses a feature that is currently in development. You can work with this capability in it's development and beta stages by downloading and building the Trunk source code.
The Crafter Engine full-text search is provided by Apache Solr Server. Solr can be downloaded here (version 3.5 or higher). For development, you may use the example Solr server in the ./example folder. Otherwise, the Solr server itself is in a WAR file, for example, apache-solr-3.5.0/dist/apache-solr-3.5.0.war.
To deploy Solr to a Tomcat instance, say in /Applications/Alfresco/preview-tomcat-6.0.35, do the following:
There are two primary Solr configuration files: solr/conf/solrconfig.xml and solr/conf/schema.xml. For the example server, use solrconfig.xml as is. For a Tomcat instance, edit solr/conf/solrconfig.xml and comment out the Velocity related settings as follows:
For schema.xml, add two key settings for Crafter Engine (you can delete other <copyField source= ... dest="text"> elements):
|These two items allow Crafter to index and search on arbitrary data models, such as the model prototypes used by Crafter Studio. The dynamic field feature of Solr may be critical in future offering of Crafter in a multi-tenant deployment, in which the party hosting Crafter does not control what content to be indexed by Solr.|
To run the example Solr server (on TCP port 8983 by default), do the following:
To run Solr in Tomcat, copy the Solr WAR to and rename it as webapps/solr.war:
There are two main Solr documentations online: the Tutorial and the Wiki.
Basic concept: a document is a set of fields of text.
Common operations: Add, Update, Delete, Query
Crafter Engine here refers to the one in cstudio-trunk/cengine/cengine-war/target/ROOT.war deployed in Crafter Studio or its preview server.
The Solr search engine can be configured to run in the same Tomcat instance as Crafter Studio or in a separate instance of Tomcat. For the latter case, if the Solr server is not running at localhost:8983, set crafter.solrServerUrl accordingly in shared/classes/crafter/cengine/extension/server-config.properties. Be sure to include the application path "/solr" at the end, for example:
Most pages in the ACME Demo Site offer a check box "Show Search Box" in their page setting section (available in 2.0.1). When checked, an input box and a search button will appear in the top navigation bar of the page. Type in any phrase will produce a search result that enumerate all fields in the model prototype. The searched phrase(s) will be highlighted in italic font.
The search box submits the query to a Spring MVC search controller. The controller queries the Solr server and returns a result model to a FreeMarker view.This model has 3 top level objects:
- response (contains a list of hit documents)
- responseHeader (not used)
- highlighting (contains the Solr highlighting result)
The FreeMarker view renders the model using template wem-projects/acme/acmecom/templates/web/search.ftl. The search.ftl template also uses a function called showSolrResult defined in templates/system/common/cengine-support.ftl.