A new feature has appeared in beta version in Datafari 4.1, it is the categories context for search. It is splitted in two parts : a suggester and a corresponding category that defines a search behavior when the category is selected.
The suggester
The suggester is used to try to predict that the user search belongs to a category and propose a "special option" in the autocomplete to perform the search in that specific category. If the user select that suggester option, in addition to perform the search in the category, Datafari may be able to change the way the results are displayed (depending on what was implemented in the code).
To configure a suggester for a category you will first need to create a new suggest request handler in Solr, based on the desired category field. Then you will need to edit AUTOCOMPLETESUGGESTERS variable in the configuration file DATAFARi_HOME/tomcat/conf/entity-autocomplete.properties :Code Block AUTOCOMPLETESUGGESTERS=[{"i18nKey":"asAuthor", "serverUrl":"", "servlet":"suggestAuthors", "maxSuggest":1, "categoryKey":"authors", "categoryi18nKey":"authors"}]
This variable must contain a json array, composed by a list of json objects having the following fields :
- i18nKey
- serverUrl
- servlet
- maxSuggest
- categoryKey
- categoryi18nKey i18nKey : the i18n key to use fort the autocomplete label. The autocomplete label is built like this : [Proposal] [i18n label]. For example, for the author category, an autocomplete proposal could be : Hawkins as author. The "as author" sentence would be retrieved thanks to the "asAuthor" entry in the i18n files located in DATAFARI_HOME/tomcat/webapp/Datafari/js/AjaxFranceLabs/locale/. Of course you will need to create you desired i18n key and associated label in each language file
- serverUrl : if the suggest request handler to request is located and reachable from an other server than the Datafari main one, you will need to enter its address in this variable
- servlet : the servlet name associated to the suggest request handler
- maxSuggest : maximum number of category suggestions to display in the autocomplete
- categoryKey : the key name of the category corresponding to the suggester request handler. The key name must match to a field name in the CATEGORIES variable of the DATAFARi_HOME/tomcat/conf/entity-autocomplete.properties file
- categoryi18nKey : i18 key name for the category. Must have a matching entry in the language files located in DATAFARI_HOME/tomcat/webapp/Datafari/js/AjaxFranceLabs/locale/The category
Like described in the part 1, each suggester must be associated to a category. The categories are defined in the CATEGORIES variable of the DATAFARi_HOME/tomcat/conf/entity-autocomplete.properties file :Code Block CATEGORIES={"authors":{"queryPrefix":"author_search:(", "querySuffix":")", "solrCore":"", "requestHandler":""}}
This variable must contain a json object composed of categories keyname as fields and json objects as values representing the categories specific options :
- queryPrefix : a query prefix to add to each search for this category
- querySuffix : a query suffix to add to each search for this category
- solrCore : the Solr Core to request if it differs from the default one "FileShare"
- requestHandler : the request handler to request to execute the query if it differs from the default one "/select"
These are the pre-configured options of the beta version of the categories features. You can add more options like filter queries, field list etc. but you will need to write some code to handle them in the SearchProxy servlet of Datafari
To enable or disable the categories feature you will need to change the value of the ACTIVATED variable of the DATAFARi_HOME/tomcat/conf/entity-autocomplete.properties file to true or false.