# Setting up basic search service

Note that the Elastic search server can be installed on a seperate server (neither TS file indexing or the application server is required).

### <span class="mw-headline" id="bkmrk-install%3A-elastic-sea-1">Install: Elastic search server</span>

Elastic search server (version 5) will run standalone and will require Java 8 or higher

1. Download Elastic search zip archieve
2. Unpack files to suitable location
3. Start elastic.bat in /bin folder

```
  <a class="external free" href="https://www.elastic.co/downloads/elasticsearch" rel="nofollow">https://www.elastic.co/downloads/elasticsearch</a>
```

For Linux you can follow the guide in [Install with tar](https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html#_installation_example_with_tar)

```
 wget <a class="external free" href="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.9.1-x86_64.rpm" rel="nofollow">https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.9.1-x86_64.rpm</a>
 wget <a class="external free" href="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.9.1-x86_64.rpm.sha512" rel="nofollow">https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.9.1-x86_64.rpm.sha512</a>
 shasum -a 512 -c elasticsearch-8.9.1-x86_64.rpm.sha512 
 sudo rpm --install elasticsearch-8.9.1-x86_64.rpm
 sudo rpm -e elasticsearch-8.9.1-x86_64.rpm
```

Alternatively use this script

```
 sudo rpm --import <a class="external free" href="https://packages.elastic.co/GPG-KEY-elasticsearch" rel="nofollow">https://packages.elastic.co/GPG-KEY-elasticsearch</a>
 sudo sh -c 'curl <a class="external free" href="https://gist.githubusercontent.com/nl5887/b4a56bfd84501c2b2afb/raw/elasticsearch.repo" rel="nofollow">https://gist.githubusercontent.com/nl5887/b4a56bfd84501c2b2afb/raw/elasticsearch.repo</a> >> /etc/yum.repos.d/elasticsearch.repo'
 sudo yum install -y elasticsearch  
 sudo chkconfig elasticsearch on
```

```
 sudo nano /etc/elasticsearch/jvm.options
 -Xms256m
 -Xmx256m
```

```
 sudo service elasticsearch start
```

```
 curl '<a class="external free" href="http://localhost:9200/app/_count?pretty&q=%27y" rel="nofollow">http://localhost:9200/app/_count?pretty&q='y</a>
```

### <span id="bkmrk-"></span><span class="mw-headline" id="bkmrk-install%3A-ts-file-ind-1">Install: TS file indexing service (TSFIS)</span>

For TSFIS to run yo will need a servlet container (Tomcat,JBoss,Oracle AS).

1. Download tsFileIndexingService.war
2. Dump to webapplication folder on application server
3. Change settings in web.xml 
    - Database connection strings: If on same server just copy the seeting from your main application
    - ExecutableGhostscript: Path to Ghostscript (see above)
    - ExecutableTerrasect: Path to Terrasect OCR module (see above)
    - ElasticServerAddress: IP or servername where ElastisSearch is installed (see above)
4. Restart server (to reload DB credentials)
5. Test application at: &lt;server&gt;/tsFileIndexingService/execute

### <span class="mw-headline" id="bkmrk-network-configuratio-1">Network configuration</span>

In the event that Elastic search or the file indexer is not on the same server you will need to ensure that

- Open port 3306 fra **TS file indexing service** to **MySQL database** (normally the application server)
- Open port 2100 fra **TS file indexing service** to **ElasticSearch** server
- Open port 2100 fra **Tempus Serva application** to **ElasticSearch** server

Also remember to update configrations for server names

- Elastic search: elasticsearch.yml file &gt; network.host (add IP or servername) 
    - [https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html)
- TS file indexing service: web.xml &gt; ElasticServerAddress (elastic search server)
- Tempus Serva application: Server policies 
    - fulltextFileHandlerURL (file indexing server)
    - fulltextElasticBaseURL (elastic search server)

### <span class="mw-headline" id="bkmrk-multi-application-se-1">Multi application setup</span>

1. Setup a shared table for **lucenefilequeue** using views 
    - Delete the lucenefilequeue table in all slave databases
    - Create a view of lucenefilequeue pointing to the master database
2. **TS file indexing service** must have a user with access to all TS databases

Multiple instances will have a shard each in the Elastic index