In this tutorial, we will see how to add a facet in Ajaxfrancelabs. The facet here will be a facet field, that means that the source of the faceting are the different values of the Solr field.
...
Edit custom_fields.incl located in /opt/datafari/solr/solr_home/FileShare/conf/customs_
schema and schema
and add your new field in JSON format. It needs to be at least indexed (not necessarily stored) and not tokenized so if I want to add the field named job, the configuration will be :
Code Block | ||
---|---|---|
| ||
{ "name":"job", "type":"string", "stored":true, "multiValued":false } |
Don't forget to save your changes into the file.
Launch the script addCustomSchemaInfoscript
addCustomSchemaInfo.sh
Launch the script addCustomSchemaInfoscript addCustomSchemaInfo.sh
located into /opt/datafari/solr/solr_home/FileShare/conf/customs_schema
:
Code Block |
---|
cd /opt/datafari/solr/solr_home/FileShare/conf/customs_schema
bash addCustomSchemaInfo.sh |
...
Info |
---|
note that you can also do it directly by the Solr Admin UI BUT keep in mind that the modifications done will be added in the To do so : Access the Datafari Admin UI > Search Engine Administration > Solr Administration > collection = FileShare > schema > add field > name = "job" (for this example) > field type = "string" > stored = TRUE > indexed = TRUE |
After that, verify that the new field is present by selecting "index fields" in the admin UI > Search Engine Administration > Index Fields > Scroll down list of fields to confirm that "job" is present.
...
Our field is correctly present in our Solr schema and the values are present for each document. We just now have to configure the faceting in Ajaxfrancelabs.
We need to modify the search.js
file in order to add the TableFacet widget, we also have to add the facet display in the searchView.jsp
and finally add the label of the facet in the i18n files : en.json
and fr.json
.
First, edit the file
search.js
into/opt/datafari/tomcat/webapps/Datafari/js
, add the widget in the code :
...
We need to have an unique identifier in elm and id, we choose to call it facet_job, in the field parameter we indicate job, for the name we put job.
The file seems looks like that this :
...
Edit now the file
searchView.jsp
located in/opt/datafari/tomcat/webapps/Datafari
We add the facet element to display on the page.We add it on the div section called col left :
...
Ok now the final step is to localize the label name of our new facet. Let's edit the two files
en.json
andfr.json
in/opt/datafari/tomcat/webapps/Datafari/js/AjaxFranceLabs/locale
:
We add a new line for the parameter 'job'. Here we add the same value for both the languages : Job. So the line to add is :
Code Block | ||
---|---|---|
| ||
"job" : "Job", |
Screenshot of the fr.json
file :
...
The configuration is now over. We can check if our new facet is correctly displayed in Datafari :
...
It seems to be the case. We can now filter the results by the ManifoldCF job : documents from Datafari website or France Labs website !