FreeBSD Elasticsearch - How to Enable Full Text Search App Store on NextCloud

One of Nextcloud's capabilities is supporting search through the web interface and in the client. In this mode, the search is based on the name of the file being compared and the contents of the file are not searched. However, there are other options that can be used to set up a full text search.

The Elasticsearch application is often used as a means for organizations or companies to present information quickly and efficiently. Thanks to its flexibility and versatility, Elasticsearch is one of the most widely used and popular search engines in the world.

On Nextcloud servers, Elasticsearch is the backbone of Full-text search. If you want to use Elasticsearch as a search engine, Nextcloud and Elasticsearch must be installed separately or independently. Elasticsearch is a Java-based search engine, so the first step is to ensure that Java is installed. You should check whether Java is installed on your FreeBSD server.

1. Install Elasticsearch

On FreeBSD, the Elasticsearch configuration process is very simple and the installation process is not too complicated. You just need to install Elasticsearch via pkg package by typing the command below.

Update Package PKG
root@ns3:~ # pkg update -f
root@ns3:~ # pkg upgrade -f
Install Elasticsearch
root@ns3:~ # pkg install elasticsearch8
After that, you activate elasticsearch7 so that it can run automatically when the computer reboots.

root@ns3:~ # ee /etc/rc.conf
We continue by installing Java openjdk17.

root@ns3:~ # cd /usr/ports/java/openjdk17
root@ns3:~ # make install clean
You can read a complete guide on how to install Java OpenJDK on FreeBSD in the following article.

Installing and Configuring Java openjdk17 in FreeBSD 13

Since we will be using "Elasticsearch" with Nextcloud's "Full Text Search", the PHP readline library is needed to connect Elasticsearch and Full Text Search. Run the following command to install PHP readline.

Install php82-readline
root@ns3:~ # pkg install php82-readline
The next step is to configure the elasticsearch.yml file. Activate some scripts like the example below.

root@ns3:~ # ee /usr/local/etc/elasticsearch/elasticsearch.yml nextcloud2 node-1 /var/db/elasticsearch
path.logs: /var/run/elasticsearch
bootstrap.memory_lock: true
http.port: 9200
discovery.seed_hosts: ["", "[::1]"]
discovery.type: single-node false false false
Add the ingestion plugin Elasticsearch.

Install plugin elasticsearch
root@ns3:~ # /usr/local/lib/elasticsearch/bin/elasticsearch-plugin install ingest-attachment
Restart Elasticsearch.

Restart elasticsearch
root@ns3:~ # service elasticsearch restart
Check whether elasticsearch is running or not.

Check elasticsearch
root@ns3:~ # curl -XGET ''

2. Install Full Text Search Nextcloud

After you have finished installing Elasticsearch, continue by installing Nextcloud Full Text Search. Follow the commands below to install and activate Full Text Search.

Install Full Tetxt Search
root@ns3:~ # occ app:install files_fulltextsearch
root@ns3:~ # occ app:install fulltextsearch
root@ns3:~ # occ app:install fulltextsearch_elasticsearch
After that, you activate Full Text Search.

Enable Full Tetxt Search
root@ns3:~ # occ app:enable files_fulltextsearch
root@ns3:~ # occ app:enable fulltextsearch
root@ns3:~ # occ app:enable fulltextsearch_elasticsearch
Now you can directly connect Nextcloud with elastic search. Please log in to your Nextcloud account, then click the Administration settings menu and the Full text search menu. Follow the image guide below.

In the "Address of the Servlet" menu, type the elasticsearch IP address, namely "". In the index menu, also type "nextcloud2", adapt it to the script " nextcloud2" in the elasticsearch.yml file.

After that you run Generate search index, the search index structure is done in the console with the command line, below is an example of the command you have to run.

Generating the search index
root@ns3:~ # cd /usr/local/www/nextcloud
root@ns3:/usr/local/www/nextcloud # occ fulltextsearch:index
To ensure the full text search has been indexed into the Nextcloud "App Store", run the two command lines below.

Check and test
root@ns3:/usr/local/www/nextcloud # occ fulltextsearch:check
root@ns3:/usr/local/www/nextcloud # occ fulltextsearch:test
The final step is to run the Apache web server.

Run Apache24
root@ns3:~ # service apache24 restart
By setting this section on the Nextcloud website, now your Nextcloud server is connected to elasticsearch. You can perform searches efficiently, securely and with high performance. Not only that, elasticsearch is also able to analyze data quickly and in large amounts.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post