/
Add Yellow pages feature into Datafari

Add Yellow pages feature into Datafari

The yellow pages feature is not integrated by default into Datafari. You have to activate it by doing few steps that we will explain here.

The yellow pages feature allows the user to display a graphical widget related to user information like from a directory.

 

 

To activate it, you have to do modifications into Datafari, Solr and activate the widget into DatafariUI.

1.Datafari part

First you have to authorize a new search handler into the datafari.properties file. So edit the file :

nano $DATAFARI_HOME/tomcat/conf/datafari.properties

And add /select_directlinks into the userAllowedHandlers property :

userAllowedHandlers=/select_directory

You need to restart Datafari :

cd $DATAFARI_HOME/bin bash restart-datafari.sh

 

  1. Solr part

  • Add fields into the schema

To do that, you need to edit the file custom_fields.incl into $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_schema :

nano $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_schema/custom_fields.incl

And add :

{ "name":"directory_name", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_firstnames", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_role", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_phone", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_email", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_picture", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_expertise", "multiValued":true, "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_socialnetworks", "multiValued":true, "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_department", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_location", "type":"text_fr", "indexed": true, "stored":true } && { "name":"directory_type", "type":"text_fr", "indexed": true, "stored":true }

Then you need to send the modifications the changes to Solr by executing the script addCustomSchemaInfo.sh into the same folder :

cd $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_schema bash addCustomSchemaInfo.sh

 

We did the modifications on the schema we can now do the modifications into solrconfig.

  • Add the configuration of a new handler

Edit the file custom_search_handler.incl into $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_solrconfig :

nano $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_solrconfig/custom_search_handler.incl

And add this handler :

<requestHandler class="solr.SearchHandler" name="/select_directory"> <lst name="defaults"> <str name="echoParams">explicit</str> <str name="defType">edismax</str> <str name="qf">directory_name directory_firstnames directory_role directory_phone directory_email directory_expertise directory_socialnetworks directory_department directory_location</str> <str name="qf">directory_name directory_firstnames directory_role directory_phone directory_email directory_expertise directory_socialnetworks directory_department directory_location</str> <int name="rows">10</int> <str name="spellcheck">true</str> <str name="spellcheck.onlyMorePopular">true</str> <str name="spellcheck.count">1</str> <str name="spellcheck.collate">true</str> <str name="spellcheck.maxCollationTries">1</str> <str name="spellcheck.extendedResults">true</str> <str name="hl">on</str> <str name="hl.method">unified</str> <str name="hl.defaultSummary">false</str> <str name="hl.tag.pre">&lt;span class="em"&gt;</str> <str name="hl.tag.post">&lt;/span&gt;</str> <str name="hl.fl">content_fr content_en content_de content_es exactContent</str> <str name="hl.requireFieldMatch">true</str> <str name="hl.bs.type">WORD</str> <str name="hl.encoder">html</str> <str name="hl.fragsize">200</str> <str name="hl.maxAnalyzedChars">51200</str> <int name="facet.mincount">1</int> <!-- clustering for tags cloud <bool name="clustering">${clustering.enabled:false}</bool> <str name="clustering.engine">lingo</str> <bool name="clustering.results">true</bool> <str name="carrot.url">id</str> <str name="carrot.title">title</str> <str name="carrot.snippet">content_en,content_fr</str> <bool name="carrot.produceSummary">true</bool> <str name="carrot.lang">language</str>--> </lst> <arr name="last-components"> <str>spellcheck</str> <str>elevator</str> <!-- <str>clustering</str> --> </arr> <lst name="appends"> <str name="fq">{!manifoldCFSecurity}</str> <str name="fq">repo_source:directory</str> </lst> </requestHandler>

You can customize the configuration if you need to.

  • Modify the main search handler configuration (/select) :

– Comment or Delete the /select configuration into solrconfig.xml located into $DATAFARI_HOME/solr/solrcloud/FileShare/conf

nano $DATAFARI_HOME/solr/solrcloud/FileShare/conf/solrconfig.xml

Copy all the /select handler section into the file and comment it or delete it :

 

 

– Copy the select handler configuration that you just commented or deleted and paste it into the file custom_search_handler.incl located into $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_solrconfig :

nano $DATAFARI_HOME/solr/solrcloud/FileShare/conf/customs_solrconfig/custom_search_handler.incl

 

 

– Do a change into this configuration before saving the file :

You need to add a fq line into appends section of the file :

<str name=”fq”>-repo_source:directory</str>

So all the section is like that :

<lst name="appends"> <str name="fq">{!manifoldCFSecurity}</str> <str name="fq">-repo_source:directory</str> </lst>

This is now the entire file :

 

 

We have now to push this configuration to Solr, for this use the Datafari admin UI :
- Go to Search Engine Configuration → System Configuration Manager

Then click into Push button then Apply button :

 

– Check the Solr admin UI to see if there are any errors :

Go to Solr admin UI then into Logging menu :

 

If all seems correct, we can add some data now !

  • Add some data for direct links

The easiest is to use CSV format. Create a CSV file with the data and upload it to Solr.

– Create the CSV file

Create the file whereever you want into the Datafari server. In our example it will be into /var/datafari :

nano /var/datafari/directory.csv

This is an example of data :

id,title,content_fr,url,directory_name,directory_firstnames,directory_role,directory_phone,directory_email,directory_picture,directory_expertise,directory_socialnetworks,directory_department,directory_location,directory_type,repo_source,content,content_en,preview_content,exactContent directory1,directory1,directory1,directory1,durand,jean,CEO,0111223344,jean.durand@acme.company,https://www.acme.com/1,business,durand1,CEO,Paris,personne,directory,notext,notext,notext,notext directory2,directory2,directory2,directory2,bertrand,eric,ingenieur,0233445566,eric.bertrand@acme.company,https://www.acme.com/2,business,bertranddu69,informatique,Nice,personne,directory,notext,notext,notext,notext

– Then send it to Solr :

cd /var/datafari curl 'http://localhost:8983/solr/FileShare/update?commit=true&escape=\' --data-binary @./directory.csv -H 'Content-type:application/csv'

You need to adapt the Solr URL if you are into multiservers mode into Datafari EE.

 

  1. DatafariUI part

It is the simplest part, you just have to activate the widget into your ui-config.json file located into $DATAFARI_HOME/www/ :

nano $DATAFARI_HOME/www/ui-config.json

And change the property show to true instead of false for the yellow pages widget :

{ "type": "YellowPagesWidget", "title": "Yellow Pages", "show": true, "visible": 1 }

And voilà ! Your widget should be displayed into your Datafari UI now :

 

Related content