- Installing Solr
- Available Solr Packages
- Preparing for Installation
- Package Installation
- Directory Layout
- Solr Examples
- Starting Solr
- Start Solr with a Specific Bundled Example
- Check if Solr is Running
- Create a Core
- Installing Solr
- Available Solr Packages
- Preparing for Installation
- Package Installation
- Directory Layout
- Solr Examples
- Starting Solr
- Start Solr with a Specific Bundled Example
- Check if Solr is Running
- Create a Core
- Установка SOLR и базовая настройка пакета на Debian
- Поиск в Solr посредством HTTP запросов
- Создание индексов Solr и добавление данных в них
- Installation & Configuration of Apache solr server 4.6 on Windows Machine
- Installing & configuring Apache Solr-5.2.0 with Drupal 7 using Search API on Ubuntu 14.04
- Configure Apache Solr with Drupal for better content search
- How to highlight search results in Search API Solr View in Drupal 8
Installing Solr
Installation of Solr on Unix-compatible or Windows servers generally requires simply extracting (or, unzipping) the download package.
Please be sure to review the Solr System Requirements before starting Solr.
Available Solr Packages
Solr is available from the Solr website. Download the latest release https://lucene.apache.org/solr/downloads.html.
There are three separate packages:
solr-8.8.0.tgz for Linux/Unix/OSX systems
solr-8.8.0.zip for Microsoft Windows systems
solr-8.8.0-src.tgz the package Solr source code. This is useful if you want to develop on Solr without using the official Git repository.
Preparing for Installation
When getting started with Solr, all you need to do is extract the Solr distribution archive to a directory of your choosing. This will suffice as an initial development environment, but take care not to overtax this «toy» installation before setting up your true development and production environments.
When you’ve progressed past initial evaluation of Solr, you’ll want to take care to plan your implementation. You may need to reinstall Solr on another server or make a clustered SolrCloud environment.
When you’re ready to setup Solr for a production environment, please refer to the instructions provided on the Taking Solr to Production page.
How to size your Solr installation is a complex question that relies on a number of factors, including the number and structure of documents, how many fields you intend to store, the number of users, etc.
It’s highly recommended that you spend a bit of time thinking about the factors that will impact hardware sizing for your Solr implementation. A very good blog post that discusses the issues to consider is Sizing Hardware in the Abstract: Why We Don’t have a Definitive Answer.
One thing to note when planning your installation is that a hard limit exists in Lucene for the number of documents in a single index: approximately 2.14 billion documents (2,147,483,647 to be exact). In practice, it is highly unlikely that such a large number of documents would fit and perform well in a single index, and you will likely need to distribute your index across a cluster before you ever approach this number. If you know you will exceed this number of documents in total before you’ve even started indexing, it’s best to plan your installation with SolrCloud as part of your design from the start.
Package Installation
To keep things simple for now, extract the Solr distribution archive to your local home directory, for instance on Linux, do:
Once extracted, you are now ready to run Solr using the instructions provided in the Starting Solr section below.
Directory Layout
After installing Solr, you’ll see the following directories and files within them:
Solr’s Admin UI ( server/solr-webapp )
Jetty libraries ( server/lib )
Log files ( server/logs ) and log configurations ( server/resources ). See the section Configuring Logging for more details on how to customize Solr’s default logging.
Sample configsets ( server/solr/configsets )
Solr Examples
Solr includes a number of example documents and configurations to use when getting started. If you ran through the Solr Tutorial, you have already interacted with some of these files.
Here are the examples included with Solr:
Starting Solr
Solr includes a command line interface tool called bin/solr (Linux/MacOS) or bin\solr.cmd (Windows). This tool allows you to start and stop Solr, create cores and collections, configure authentication, and check the status of your system.
To use it to start Solr you can simply enter:
If you are running Windows, you can start Solr by running bin\solr.cmd instead.
This will start Solr in the background, listening on port 8983.
When you start Solr in the background, the script will wait to make sure Solr starts correctly before returning to the command line prompt.
Start Solr with a Specific Bundled Example
Currently, the available examples you can run are: techproducts, dih, schemaless, and cloud. See the section Running with Example Configurations for details on each example.
Running the cloud example starts Solr in SolrCloud mode. For more information on starting Solr in SolrCloud mode, see the section Getting Started with SolrCloud.
Check if Solr is Running
If you’re not sure if Solr is running locally, you can use the status command:
This will search for running Solr instances on your computer and then gather basic information about them, such as the version and memory usage.
That’s it! Solr is running. If you need convincing, use a Web browser to see the Admin Console.
Figure 1. The Solr Admin interface.
If Solr is not running, your browser will complain that it cannot connect to the server. Check your port number and try again.
Create a Core
If you did not start Solr with an example configuration, you would need to create a core in order to be able to index and search. You can do so by running:
This will create a core that uses a data-driven schema which tries to guess the correct field type when you add documents to the index.
To see all available options for creating a new core, execute:
Installing Solr
Installation of Solr on Unix-compatible or Windows servers generally requires simply extracting (or, unzipping) the download package.
Please be sure to review the Solr System Requirements before starting Solr.
Available Solr Packages
Solr is available from the Solr website. Download the latest release https://lucene.apache.org/solr/mirrors-solr-latest-redir.html.
There are three separate packages:
solr-7.0.0.tgz for Linux/Unix/OSX systems
solr-7.0.0.zip for Microsoft Windows systems
solr-7.0.0-src.tgz the package Solr source code. This is useful if you want to develop on Solr without using the official Git repository.
Preparing for Installation
When getting started with Solr, all you need to do is extract the Solr distribution archive to a directory of your choosing. This will suffice as an initial development environment, but take care not to overtax this «toy» installation before setting up your true development and production environments.
When you’ve progressed past initial evaluation of Solr, you’ll want to take care to plan your implementation. You may need to reinstall Solr on another server or make a clustered SolrCloud environment.
When you’re ready to setup Solr for a production environment, please refer to the instructions provided on the Taking Solr to Production page.
How to size your Solr installation is a complex question that relies on a number of factors, including the number and structure of documents, how many fields you intend to store, the number of users, etc.
It’s highly recommended that you spend a bit of time thinking about the factors that will impact hardware sizing for your Solr implementation. A very good blog post that discusses the issues to consider is Sizing Hardware in the Abstract: Why We Don’t have a Definitive Answer.
Package Installation
To keep things simple for now, extract the Solr distribution archive to your local home directory, for instance on Linux, do:
Once extracted, you are now ready to run Solr using the instructions provided in the Starting Solr section below.
Directory Layout
After installing Solr, you’ll see the following directories and files within them:
This directory includes several important scripts that will make using Solr easier.
This is Solr’s Control Script, also known as bin/solr (*nix) / bin/solr.cmd (Windows). This script is the preferred tool to start and stop Solr. You can also create collections or cores, configure authentication, and work with configuration files when running in SolrCloud mode.
The PostTool, which provides a simple command line interface for POSTing content to Solr.
solr.in.sh and solr.in.cmd
This script is used on *nix systems to install Solr as a service. It is described in more detail in the section Taking Solr to Production.
Solr’s contrib directory includes add-on plugins for specialized features of Solr.
The docs directory includes a link to online Javadocs for Solr.
The example directory includes several types of examples that demonstrate various Solr capabilities. See the section Solr Examples below for more details on what is in this directory.
The licenses directory includes all of the licenses for 3rd party libraries used by Solr.
This directory is where the heart of the Solr application resides. A README in this directory provides a detailed overview, but here are some highlights:
Solr’s Admin UI ( server/solr-webapp )
Jetty libraries ( server/lib )
Log files ( server/logs ) and log configurations ( server/resources ). See the section Configuring Logging for more details on how to customize Solr’s default logging.
Sample configsets ( server/solr/configsets )
Solr Examples
Solr includes a number of example documents and configurations to use when getting started. If you ran through the Solr Tutorial, you have already interacted with some of these files.
Here are the examples included with Solr:
This is a small set of simple CSV, XML, and JSON files that can be used with bin/post when first getting started with Solr. For more information about using bin/post with these files, see Post Tool.
This directory includes a few example DataImport Handler (DIH) configurations to help you get started with importing structured content in a database, an email server, or even an Atom feed. Each example will index a different set of data; see the README there for more details about these examples.
The files directory provides a basic search UI for documents such as Word or PDF that you may have stored locally. See the README there for details on how to use this example.
The films directory includes a robust set of data about movies in three formats: CSV, XML, and JSON. See the README there for details on how to use this dataset.
Starting Solr
Solr includes a command line interface tool called bin/solr (Linux/MacOS) or bin\solr.cmd (Windows). This tool allows you to start and stop Solr, create cores and collections, configure authentication, and check the status of your system.
To use it to start Solr you can simply enter:
If you are running Windows, you can start Solr by running bin\solr.cmd instead.
This will start Solr in the background, listening on port 8983.
When you start Solr in the background, the script will wait to make sure Solr starts correctly before returning to the command line prompt.
Start Solr with a Specific Bundled Example
Currently, the available examples you can run are: techproducts, dih, schemaless, and cloud. See the section Running with Example Configurations for details on each example.
Running the cloud example starts Solr in SolrCloud mode. For more information on starting Solr in cloud mode, see the section Getting Started with SolrCloud.
Check if Solr is Running
If you’re not sure if Solr is running locally, you can use the status command:
This will search for running Solr instances on your computer and then gather basic information about them, such as the version and memory usage.
That’s it! Solr is running. If you need convincing, use a Web browser to see the Admin Console.
If Solr is not running, your browser will complain that it cannot connect to the server. Check your port number and try again.
Create a Core
If you did not start Solr with an example configuration, you would need to create a core in order to be able to index and search. You can do so by running:
This will create a core that uses a data-driven schema which tries to guess the correct field type when you add documents to the index.
To see all available options for creating a new core, execute:
Установка SOLR и базовая настройка пакета на Debian
Создадим каталог под файлы java
Далее — симовльную ссылку /opt/java/default к библиотеке /usr/lib/jvm/java-7-openjdk-amd64
Слоздаем каталог под файлы пакета и переходим в него
Скачиваем исходники Solr
Затем переходим в каталог solr-5.5.5, при установке пакета создаются тестовые файлы, которые можно использовать
В каталоге с файлами пакета будет README.txt, в котором содержится довольно полная информация по его использованию.
В частности, имеются инструкции по работе с примерами
cloud : SolrCloud example
dih : Data Import Handler (rdbms, mail, rss, tika)
schemaless : Schema-less example (schema is inferred from data during indexing)
techproducts : Kitchen sink example providing comprehensive examples of Solr features
Creating Solr home directory /opt/solr/solr-5.5.5/example/techproducts/solr
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.
Started Solr server on port 8983 (pid=8433). Happy searching!
Copying configuration to new core instance directory:
/opt/solr/solr-5.5.5/example/techproducts/solr/techproducts
Creating new core ‘techproducts’ using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=techproducts&instanceDir=techproducts
<
«responseHeader»:<
«status»:0,
«QTime»:3353>,
«core»:»techproducts»>
Indexing tech product example docs from /opt/solr/solr-5.5.5/example/exampledocs
SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/techproducts/update using content-type application/xml…
POSTing file mem.xml to [base]
POSTing file mp500.xml to [base]
POSTing file ipod_video.xml to [base]
POSTing file manufacturers.xml to [base]
POSTing file gb18030-example.xml to [base]
POSTing file vidcard.xml to [base]
POSTing file monitor.xml to [base]
POSTing file monitor2.xml to [base]
POSTing file utf8-example.xml to [base]
POSTing file solr.xml to [base]
POSTing file hd.xml to [base]
POSTing file ipod_other.xml to [base]
POSTing file money.xml to [base]
POSTing file sd500.xml to [base]
14 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/techproducts/update…
Time spent: 0:00:00.634
Solr techproducts example launched successfully. Direct your Web browser to http://localhost:8983/solr to visit the Solr Admin UI
Solr уcтановлен и доступен в веб-интерфейсе
В браузере теперь потребуется ввести IP адрес сервера, номер порта, /solr
http://123.123.123.123:8983/solr
Дополнительной настройка веб-сервера и его виртуальных хостов не требуется.
Статус ноды можно посмотреть следующим образом:
Found 1 Solr nodes:
Solr process 8433 running on port 8983
<
«solr_home»:»/opt/solr/solr-5.5.5/example/techproducts/solr»,
«version»:»5.5.5 b3441673c21c83762035dc21d3827ad16aa17b68 — sarowe — 2017-10-20 09:02:42″,
«startTime»:»2017-11-18T17:24:17.602Z»,
«uptime»:»0 days, 0 hours, 10 minutes, 54 seconds»,
«memory»:»43.1 MB (%8.8) of 490.7 MB»>
Если сервер требуется остановить это можно сделать так:
Пакет позволяет искать данные в XML файлах. Для примера доступны некоторые образцы, увидеть их можно в example/exampledocs/
USD
One Dollar
Bank of America
boa
В том же каталоге находится post.jar, с помощью которого в индекс добавляются данные
SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/techproducts/update using content-type application/xml…
POSTing file money.xml to [base]
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/techproducts/update…
Time spent: 0:00:00.141
Также добавим еще один документ:
Данные в Solr можно добавлять двумя способами:
Поиск в Solr посредством HTTP запросов
Поисковые запросы можно отправлять по HTTP:
http://123.123.123.123:8983/solr/techproducts/select?q=solr&wt=json
Результат в браузере будет выглядеть следующим образом:
«numFound»:1,
«name»:»Solr, the Enterprise Search Server»,
«manu»:»Apache Software Foundation»,
«cat»:[«software»,»search»],
«Advanced Full-Text Search Capabilities using Lucene»,
«Optimized for High Volume Web Traffic»,
«Standards Based Open Interfaces — XML and HTTP»,
«Comprehensive HTML Administration Interfaces»,
«Scalability — Efficient Replication to other Solr Search Servers»,
«Flexible and Adaptable with XML configuration and Schema»,
«Good unicode support: héllo (hello with an accent over the e)»],
«price»:0.0,»price_c»:»0.0,USD»,
«popularity»:10,
«inStock»:true,»incubationdate_dt»:»2006-01-17T00:00:00Z»,
«_version_»:1584428112760799232>]>>
http://123.123.123.123:8983/solr/techproducts/select?q=popularity:10&wt=json&fl=cat,name
«status»:0,»QTime»:5,
«q»:»popularity:10″,
Как можно видеть имеем 2 результата, удовлетворяющих запросу (популярность — 10 ): продукт компании Apple и непосредственно программынй пакет для поиска Solr. Один из результатов нашелся в добавленном в индекс money.xml, другой в solr.xml
Создание индексов Solr и добавление данных в них
Можно создать новый индекс и добавить необходимую информацию, индекс создается так (index не ключевое слово, а просто имя):
Copying configuration to new core instance directory:
/opt/solr/solr-5.5.5/example/techproducts/solr/index
Creating new core ‘index’ using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=index&instanceDir=index
<
«responseHeader»:<
«status»:0,
«QTime»:1584>,
«core»:»index»>
По созданным индексам и производится поиск.
Используя curl легко добавлять документы в созданный индекс (обращение к localhost производится только с того же сервера, на котором установлен Solr)
К имени полей можно добавлять _t, если ключ использован становится возможен полнотекстовый поиск. Например, author_t
Запускам перестроение индекса (сделать это можно в том числе обращаясь с другого сервера по белому IP адресу)
Как только это сделано — можно искать информацию по индексу
Solr хорош и тем, что может эффективно находить данные по неточным запросам. В больших проектах сервера с Solr объединяются в кластерные структуры, при больших нагрузках пакет дает значительно лучшую производительность, чем аналоги.
Installation & Configuration of Apache solr server 4.6 on Windows Machine
I was working on one of the projects where the client was not satisfied with the existing drupal search as it was not able to meet their requirements on the site. So they decided to go with Apache Solr.
Those who are not aware of what exactly it is, I would like to give them a very basic introduction or a description of what it does.
Related Insight
Installing & configuring Apache Solr-5.2.0 with Drupal 7 using Search API on Ubuntu 14.04
Apache Solr is an open-source search platform built upon java library. It’s one of the most popular search platform used by most websites so that it can search and index across the site and return related content based on the search query.
For more detailed information, please visit http://lucene.apache.org/solr/
So let’s begin with solr installation. To install Solr on the windows system, the machine should have [JRE] Java Runtime Environment with the right version.
Step 1: Go to cmd prompt and check for JRE with correct version.
If JRE is available in your system it will show you the version. If not then you have to install JRE
Step 2: Download require solr version from below url
https://archive.apache.org/dist/lucene/solr/
For this tutorial i have downloaded 4.6.1 from https://archive.apache.org/dist/lucene/solr/4.6.1/ Download solr-4.6.1.zip File
Step 3: Extract the Zip folder in your machine.now go to extarcted solr folder. Get inside the example folder and execute the command
As soon as you run the above command solr will start with default port 8983. That can be accessible on http://localhost:8983/solr/#/
Related Insight
Configure Apache Solr with Drupal for better content search
This will install Solr and run in the background. By default it uses the port number 8983.
You can change default port number to one of your choice.
Step 4: To Configure solr with Drupal 7.x Download solr from https://www.drupal.org/project/apachesolr download the recomended version and install as we do normal module installation.
Step 5: Go to \apachesolr-7.x-1.8\apachesolr\solr-conf\solr-4.x copy all the files to solr server directory [solr-4.6.1\example\solr\collection1\conf\] and replace them with existing files.
After replacing your file should look like.
Now your solr admin page look like
Step 6: So we are almost done with solr server setup. Let’s configure on module level
To do this we need to go to solr setting page /admin/config/search/apachesolr/settings
Fill up mandatory detail like solr server url and description and hit on Test Connection button.
Related Insight
How to highlight search results in Search API Solr View in Drupal 8
Step 7: Almost done with solr server setup and configuration, let’s do indexing by visiting default index page admin/config/search/apachesolr.
The above steps would cover up solr server installation in your windows machine with configured D7 Apache solr module.
Conclusion: The main objective of this blog is to let the windows user to install and configured solr server and also allowing them to configure with Drupal 7. In present situation we already have variant of solr server on the web but i have recommended to use 4.6.x for Drupal 7.