User:Ram (WMF)/Search

Installing MediaWiki and lucene-search-2 for debugging
These instructions are targeted at developers who want to setup an instance of MediaWiki and the Lucene based search functionality for testing and debugging; it is not the intent here to setup a production system.

Details on how to install MediaWiki are at: http://www.mediawiki.org/wiki/Installation A summary appears below along with some additional details.

archive; then rename the top-level directory to 'core' or something similar for ease of typing, e.g.      cd ~/src tar xvf mediawiki-1.20.2.tar.gz      mv mediawiki-1.20.2 core with corresponding MySql packages):    list="php5 php5-sqlite sqlite3 apache2 git default-jdk ant debhelper javahelper"     list="$list liblog4j1.2-java libcommons-logging-java libslf4j-java "     sudo apt-get install $list     cd ~/src     mkdir extensions; cd extensions     git checkout https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MWSearch.git containing:     Now point your browser (or use wget/curl to fetch the page) at http://localhost/info.php You should see lots of tables with PHP configuration info (replace localhost with appropriate host name or IP if necessary). create an sqlite DB file under it). Also make sure that all the directories from your home directory to the MediaWiki root are world readable and searchable (otherwise you'll get errors from Apache as it searches for .htaccess files), e.g.    mkdir ~/data; chmod 777 ~/data chmod 755 ~ ~/src ~/src/core stuff and also set DocumentRoot to point to the freshly unpacked MediaWiki root above. Something close to this should work (replace xyz by a proper user name):  ServerAdmin webmaster@localhost DocumentRoot /home/xyz/src/core Alias /extensions /home/xyz/src/extensions ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined php_admin_flag engine on        php_admin_flag engine off   AllowOverride All   sudo /etc/init.d/apache2 reload on-screen instructions to configure MediaWiki; at the end you'll be prompted to download the generated LocalSettings.php file and place it in the MediaWiki root directory to complete the configuration step. This step can also be done from the commandline as described next. php core/maintenance/install.php --help Documentation on the various parameters is at: http://www.mediawiki.org/wiki/Manual:Config_script You can edit the generated LocalSettings.php file manually to add additional configuration options as needed; for example, some of these may be useful: require( "$IP/../extensions/MWSearch/MWSearch.php" ); $wgLuceneHost = 'lucene-test1'; $wgLucenePort = 8123; $wgLuceneSearchVersion = '2.1'; $wgLuceneUseRelated = true; $wgEnableLucenePrefixSearch = false; $wgSearchType = 'LuceneSearch'; cd ~/src git clone https://gerrit.wikimedia.org/r/p/operations/debs/lucene-search-2.git There is a top-level README.txt file that describes how to build it; we summarize the steps below. cd lucene-search-2; ant git checkout. Create it to contain: #!/bin/bash dir=`cd $1; pwd` java -cp LuceneSearch.jar org.wikimedia.lsearch.util.Configure $dir Now run it with the full path to the MediaWiki root directory as an argument, e.g.: bash configure ~/src/core It will examine your MediaWiki configuration and generate these matching configuration files for search: lsearch.log4j lsearch-global.conf  lsearch.conf (without them you'll get Java exceptions when you run the lsearchd daemon); one way to get around this is the remove those references and use a RollingFileAppender: log4j.rootLogger=INFO, R       log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=logs/test.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=2 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d{ISO8601} %-5p %c %m%n log4j.logger.org.wikimedia.lsearch.interoperability=DEBUG wget http://dumps.wikimedia.org/simplewiktionary/20130113/simplewiktionary-20130113-pages-meta-current.xml.bz2 and build Lucene indexes from it: java -cp LuceneSearch.jar org.wikimedia.lsearch.importer.BuildAll simplewiktionary-20130113-pages-meta-current.xml.bz2 This last command is equivalent to running the build script mentioned README.txt; it creates a new directory named indexes and a number of files and directories under it. ./lsearchd & It listens for search queries on port 8123, so you can test it like this: wget http://localhost:8123/search/my_wiki/hello Logs can be found under the logs directory.
 * Download the latest release from: http://www.mediawiki.org/wiki/Download and extract the
 * Install prerequisites (if you prefer MySql to SQLite3 replace the sqlite packages below
 * Checkout the MWSearch extension from the git repository, e.g.:
 * Make sure the apache/php combo is working by creating a file named info.php at /var/www
 * Create a data directory somewhere and make it world read/write (this is to allow apache to
 * Reconfigure apache by editing /etc/apache2/sites-available/default to remove unnecessary
 * Reload apache configuration with:
 * You should now be able to point your browser at http://localhost/index.php and follow
 * The previous step can also be done from the commandline, e.g.
 * Checkout lucene-search-2:
 * Run ant to build everything; the result should be a local file named LuceneSearch.jar:
 * The README.txt file mentions running the configure script but that script is missing in the
 * The generated lsearch.log4j uses ScribeAppender which requires installation of additional packages
 * Now get an XML dump:
 * Finally, you can run the search daemon: