Skip to content

Instantly share code, notes, and snippets.

@halilim
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halilim/10603386 to your computer and use it in GitHub Desktop.
Save halilim/10603386 to your computer and use it in GitHub Desktop.
Solr Field Manual

Solr Field Manual

This is a specific setup for use with periodic MySQL import, but can be used as a general solution by excluding the irrelevant parts.

Legend

Code Description
<SOLR> E.g.: /var/lib/tomcat#/solr, /etc/solr, ...
<CORE> Core name
<INSTANCE_DIR> Generally the same as <CORE>
<URL> E.g. http://example.com:8080/solr
<SOURCE> Project source, e.g. /home/<USER>/project/

Notes

  1. The ordering of the operations is important.

Server Setup

  1. Copy data import, MySQL etc jar's (e.g. solr3.6_jars.tar.gz for Solr 3.6) into lib folder (e.g. /var/lib/tomcat#/webapps/solr/WEB-INF/lib/)

  2. Set up Tomcat Utf-8 URI’s if required (add URIEncoding="UTF-8" to <Connector...s in /etc/tomcat#/server.xml)

  3. service tomcat# restart

Setup and Maintenance

Create core

  1. mkdir <SOLR>/<CORE>

  2. cp -r example/conf <CORE>/

  3. mkdir <SOLR>/<CORE>/data
    chown tomcat: <SOLR>/<CORE>/data

  4. [OPTIONAL] Symlinking - If conf comes with the project repository and the project exists in the same host:
    sh Link_solr_conf.sh <SOURCE>/solr/conf <SOLR>/<CORE>/conf

    Get Link_solr_conf.sh here

    Notes if used:

    1. chmod a+x all folder levels in the source, e.g.
      chmod a+x /home/user /home/user/project ...
      (Link_solr_conf.sh prompts for this)
    2. Modify database credentials in <SOLR>/<CORE>/conf/db-connection.xml
  5. [OPTIONAL] Last import info - If delta import will be used
    touch <SOLR>/<CORE>/conf/dataimport.properties
    chown tomcat: <SOLR>/<CORE>/conf/dataimport.properties

  6. <URL>/admin/cores?action=CREATE&name=<CORE>&instanceDir=<INSTANCE_DIR>

  7. In <SOLR>/solr.xml, if persistent=false, add the new core

Reload config (Core Solr config)

<URL>/admin/cores?action=RELOAD&core=<CORE>

Reload data-config only (without restarting Solr)

<URL>/<CORE>/dataimport?command=reload-config

Data import

<URL>/<CORE>/dataimport?command=full-import

Import a single entity

<URL>/<CORE>/dataimport?command=full-import&entity=<ENTITY_NAME>

Usage

Query

<URL>/<CORE>/select?q=*:*&wt=json&json.nl=map&start=0&rows=10

facet.query keys

&facet.query={!key=date-last30 ex=date}date:[NOW/DAY-30DAY TO NOW/DAY+1DAY]

Multiple LocalParams

&facet.field={!ex=city,county}city

FAQ, Errors, Etc

String Error in JavaScript Scripting

"The choice of Java constructor replace matching JavaScript argument types (function,string) is ambiguous; candidate constructors are:..."
See: http://www.mirthcorp.com/community/forums/showthread.php?t=235

In short, change

`row.get("etc").replace(/.../, ...)`

to:

`new String(row.get("etc")).replace(/.../, ...)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment