Sourcefabric Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

Newscoop 4.1 Cookbook

Configuring SOLR for sysadmins

There are a few steps to use solr on your Newscoop website - you need to setup Solr updates and edit templates:

Solr installation

  • First, you must install a Java environment. On Debian or Ubuntu GNU/Linux you can do this with the command: 

    sudo apt-get install openjdk-6-jre
  • You can check the installation requirements here and for a better understanding and/or tune-up here In general the following few steps should be enough to get Solr running.
  • Download Apache/Solr from apache.
  • Unpack it in any directory you want to run it from. We will use /var/www/ as base directory in our example.
$ cp solr-4.1.0.tgz /var/www/
$ cd /var/www
$ tar xvzf solr-4.1.0.tgz

Solr setup

  • Copy over Newscoop solr configuration into the Solr.
$ cp -a /var/www/newscoop/example/solr/* /var/www/solr-4.1.0/example/solr/
  • Edit example/solr/solr.xml and add <core> for each language you are using (name must be language code) and copy en folder for each of those cores.
  • Run Solr - go to example folder and run
  • To index languages other than the default of English, edit the file /var/www/solr-4.1.0/example/solr/solr.xml and add a <core> entry for each language you are using (the name of the core must be the ISO two-letter language code). Then copy the en folder for the name of each of those additional cores.

    <cores adminPath="/admin/cores" defaultCoreName="en" host="${host:}" hostPort="${jetty.port:}" hostContext="${hostContext:}" zkClientTimeout="${zkClientTimeout:15000}">
        <core name="en" instanceDir="en" />
$ java -jar start.jar

Newscoop setup

  • All you need to do in Newscoop is to enable Solr in the custom application config file. Open (or create) newscoop/application/configs/parameters/custom_parameters.yml with your editor of choice and add this code:
        class:      Newscoop\Search\ArticleIndexer
        arguments:  ["@em", "@search.index"]
            -  { name: kernel.event_listener, event: article.delete, method: update }
  • Newscoop looks for Solr by default in http://localhost:8983/solr. If your Solr is running on a different address/port, you can override this by changing the following line in newscoop/application/configs/parameters/custom_parameters.yml:
        solr_server: "http://:/solr"

This custom_parameters.yml file will override every environment configuration.

  • Now, we need to store Newscoop content in Solr so that search can start, in other words, we need to populate the Solr index. You can run the following command manually to get some data for testing.
$ cd /var/www/newscoop
$ php application/console index:update --env=prod 100  (number of articles to be indexed; run as many times as number of indexed articles you want)

In production environments you should setup a cron job to run the same command periodically, so you update your Solr index with any new article or article changes in Newscoop.

Thats it - you have SOLR runing!

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.