Solr Introduction

From WikiOD

Remarks[edit | edit source]

This section provides an overview of what solr is, and why a developer might want to use it.

It should also mention any large subjects within solr, and link out to the related topics. Since the Documentation for solr is new, you may need to create initial versions of those related topics.

Installing SOLR[edit | edit source]

Introduction[edit | edit source]

The following procedure was tested on a test instance in AWS, with Redhat and Solr 6.1.0. You may need to adjust the process to your operating system and environment accordingly.

Prerequisites[edit | edit source]

  1. Make sure you use RedHat or a similar (Fedora-based) OS.

cat /etc/redhat-release

displays your OS version. Getting_started_with_solr

  1. Check if java 1.6 or higher is installed

which java Getting_started_with_solr

  1. Install Java if necessary

sudo yum list available java*

Getting_started_with_solr

sudo yum install java-1.8.0-openjdk.x86_64

  1. Check if it is installed correctly

which java displays the Java home

java -version displays the Java version Getting_started_with_solr

  1. Create a SOLR user.

sudo adduser solr

  1. Add a password for the user.

sudo passwd solr Getting_started_with_solr

  1. Enable sudo on the SOLR user, run visudo

sudo visudo

  1. Find the following lines:

## Allows people in group wheel to run all commands

# %wheel ALL=(ALL) ALL

  1. If %wheel is commented out, uncomment the second line by removing the # character.

%wheel ALL=(ALL) ALL Getting_started_with_solr

  1. If you made a change use :wq otherwise use :q to quit.
  2. Add the solr user to the wheel group.

sudo usermod -aG wheel solr

  1. Switch over to the solr user an check if you have root privileges:

su solr -

sudo whoami Getting_started_with_solr

Downloading SOLR[edit | edit source]

Find your local mirror at: http://www.apache.org/dyn/closer.lua/lucene/solr/

Change your directory location to opt:

cd /opt/

Download a copy of the package from the mirror:

sudo curl -O http://www.trieuvan.com/apache/lucene/solr/6.1.0/solr-6.1.0.tgz Getting_started_with_solr

Untar the package:

sudo tar zxvf solr-6.1.0.tgz

Copy the installer script to your folder:

sudo cp /opt/solr-6.1.0/bin/install_solr_service.sh .

Remove the unnecessary files:

sudo rm -rf solr-6.1.0

Install[edit | edit source]

  1. Run the install script:

sudo ./install_solr_service.sh solr-6.1.0.tgz Getting_started_with_solr

  1. Make SOLR service autostart when the server is rebooted.

sudo chkconfig --add solr

chkconfig | grep solr Getting_started_with_solr

  1. Change service owner

sudo chown -R solr:solr /var/solr/

Testing your installation[edit | edit source]

  1. Create a core from command line:

sudo su - solr -c "/opt/solr/bin/solr create -c NewCore1 -n data_driven_schema_configs" Getting_started_with_solr

  1. Open the Admin in a browser:

http://<solr_server>:8983/solr/#/ Getting_started_with_solr

  1. Open the list of cores in the menu to see the NewCore1 core. Getting_started_with_solr
  2. Test if cores are sticky:

sudo service solr restart

  1. Refresh the Admin in a browser:

http://<solr_server>:8983/solr/#/ Make sure the Admin page reloads and the core reappears after the reboot.

  1. View server status in the command line:

sudo service solr status

  1. Prepare a new core config for core creation in the Web Admin, by changing your directory location to data:

cd var/solr/data/ Getting_started_with_solr

  1. This is where the new cores are stored:

ll

  1. The newly created core's conf folder can be used as a template:

ll NewCore1/

  1. Create a folder for another core you will create in the Web Admin:

mkdir CoreFromWebAdmin

  1. Copy the conf directory over to the new location:

sudo cp -R NewCore1/conf/ CoreFromWebAdmin

  1. Switch to the Web Admin interface in your browser
  2. Click Add Core
  3. Add CoreFromWebAdmin as the name and the folder for the new core. Getting_started_with_solr
  4. Open the new core.
  5. Click documents to add docs.
  6. Select XML format and paste the code below:
<add><doc>
  <field name="id">F9V7464-APL-KIT</field>
  <field name="name">Belkin Mobile Power Cord for iPod w/ Dock</field>
  <field name="manu">Belkin</field>
  <!-- Join -->
  <field name="manu_id_s">belkin</field>
  <field name="cat">electronics</field>
  <field name="cat">connector</field>
  <field name="features">car power adapter, white</field>
  <field name="weight">4.0</field>
  <field name="price">19.95</field>
  <field name="popularity">1</field>
  <field name="inStock">false</field>
  <!-- Buffalo store -->
  <field name="store">45.18014,-93.87741</field>
  <field name="manufacturedate_dt">2005-08-01T16:30:25Z</field>
</doc>

<doc>
  <field name="id">IW-032</field>
  <field name="name">iPod &amp; iPod Mini USB 2.0 Cable</field>
  <field name="manu">Belkin</field>
  <!-- Join -->
  <field name="manu_id_s">belkin</field>
  <field name="cat">electronics</field>
  <field name="cat">connector</field>
  <field name="features">car power adapter for iPod, white</field>
  <field name="weight">2.0</field>
  <field name="price">11.50</field>
  <field name="popularity">1</field>
  <field name="inStock">false</field>
  <!-- San Francisco store -->
  <field name="store">37.7752,-122.4232</field>
  <field name="manufacturedate_dt">2006-02-14T23:55:59Z</field>
</doc>
<doc>
  <field name="id">F887464-APL-KIT</field>
  <field name="name">Belkin Mobile Power Cord for iPod w/ Dock</field>
  <field name="manu">Belkin</field>
  <!-- Join -->
  <field name="manu_id_s">belkin</field>
  <field name="cat">electronics</field>
  <field name="cat">connector</field>
  <field name="features">car power adapter, black</field>
  <field name="weight">4.0</field>
  <field name="price">19.95</field>
  <field name="popularity">1</field>
  <field name="inStock">true</field>
  <!-- Buffalo store -->
  <field name="store">45.18014,-93.87741</field>

</doc>
<doc>
  <field name="id">FAV7464-APL-KIT</field>
  <field name="name">Belkin Mobile Power Cord for iPod w/ Dock</field>
  <field name="manu">Belkin</field>
  <!-- Join -->
  <field name="manu_id_s">belkin</field>
  <field name="cat">electronics</field>
  <field name="cat">connector</field>
  <field name="features">car power adapter, blue</field>
  <field name="weight">4.0</field>
  <field name="price">15.95</field>
  <field name="popularity">2</field>
  <field name="inStock">true</field>
  <!-- Buffalo store -->
  <field name="store">45.18014,-93.87741</field>
  <field name="manufacturedate_dt">2015-09-21T16:30:25Z</field>
</doc></add>

If your response returns a success, you have successfully installed SOLR and verified your installation. Getting_started_with_solr

Introduction[edit | edit source]

Solr is a standalone enterprise search server with a REST-like API. You put documents in it (called "indexing") via JSON, XML, CSV or binary over HTTP. You query it via HTTP GET and receive JSON, XML, CSV or binary results. Solr uses the Lucene search library and extends it.

Here are some of the main features that solr provides:

* Advanced Full-Text Search Capabilities

Powered by Lucene™, Solr enables powerful matching capabilities including phrases, wildcards, joins, grouping and much more across any data type

  • Optimized for High Volume Traffic

Solr is proven at extremely large scales the world over

  • Standards Based Open Interfaces - XML, JSON and HTTP

Solr uses the tools you use to make application building a snap

  • Comprehensive Administration Interfaces

Solr ships with a built-in, responsive administrative user interface to make it easy to control your Solr instances

  • Easy Monitoring

Need more insight into your instances? Solr publishes loads of metric data via JMX

  • Highly Scalable and Fault Tolerant

Built on the battle-tested Apache Zookeeper, Solr makes it easy to scale up and down. Solr bakes in replication, distribution, rebalancing and fault tolerance out of the box.

  • Flexible and Adaptable with easy configuration

Solr's is designed to adapt to your needs all while simplifying configuration

  • Near Real-Time Indexing

Want to see your updates now? Solr takes advantage of Lucene's Near Real-Time Indexing capabilities to make sure you see your content when you want to see it

  • Extensible Plugin Architecture

Solr publishes many well-defined extension points that make it easy to plugin both index and query time plugins. Of course, since it is Apache-licensed open source, you can change any code you want!

Some solr cool features:

  • Schema when you want, schemaless when you don't

Use Solr's data-driven schemaless mode when getting started and then lock it down when it's time for production.

  • Powerful Extensions

Solr ships with optional plugins for indexing rich content (e.g. PDFs, Word), language detection, search results clustering and more

  • Faceted Search and Filtering

Slice and dice your data as you see fit using a large array of faceting algorithms

  • Geospatial Search

Enabling location-based search is simple with Solr's built-in support for spatial search

  • Query Suggestions, Spelling and More

Solr ships with advanced capabilites for auto-complete (typeahead search), spell checking and more

  • Rich Document Parsing

Solr ships with Apache Tika built-in, making it easy to index rich content such as Adobe PDF, Microsoft Word and more.

Example of Solr Search[edit | edit source]

Here is a basic example of the solr search

This article is an extract of the original Stack Overflow Documentation created by contributors and released under CC BY-SA 3.0. This website is not affiliated with Stack Overflow