How To Install Full Text Search Using Elastic Search And Nextcloud

We also install Java from ubuntu launchpad which is much easier than installing java manually

1. Install https support for apt

$ sudo apt install apt-transport-https ca-certificates

2. Install Java

Install java 8 installer from ubuntu launchpad. Add java repository

Import Ubuntu GPG key:

$ sudo apt-key adv --keyserver --recv-keys EEA14886

Add java repository:

$ echo "deb zesty main" | sudo tee -a /etc/apt/sources.list.d/java-8-debian.list

Update apt database:

$ sudo apt-get update

Installing java

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

When asked accept the “Oracle Binary Code” license.

Set Oracle JDK8 as default:

$ sudo apt install oracle-java8-set-default

Check java version:

$ java -version


java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

3. Install elasticsearch

Add elasticsearch repository

Import elasticsearch GPG key:

$ wget -qO - | sudo apt-key add -

Add elasticsearch repository:

$ echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list

Install elasticsearch package

$ sudo apt update
$ sudo apt install elasticsearch

Enable elasticsearch service

$ sudo systemctl daemon-reload
$ sudo systemctl enable elasticsearch
$ sudo systemctl start elasticsearch

Install elasticsearch ingest-attachment plugin

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment

When asked to “Continue with installation”, enter ‘y'

Bind elasticsearch to localhost only:

To force elasticsearch to listen only on localhost edit the file /etc/elasticsearch/elasticsearch.yml and set to

$ sudo nano /etc/elasticsearch/elasticsearch.yml

Inside the ‘Network' section, delete the ‘#' to uncomment the lines that starts with ‘', ‘' and ‘', and assign a custom name for each. For ‘', change the ip from to as shown below:

# [...]
# ---------------------------------- Cluster ------------------------------$
# Use a descriptive name for your cluster:
# nextcloud
# ------------------------------------ Node -------------------------------$
# Use a descriptive name for the node:
# home.lan-1


# ------------------------------ Network -------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
# [...]

The first variables to customize on any Elasticsearch server are and in elasticsearch.yml. As their names suggest, specifies the name of the server (node) and the cluster to which the latter is associated.

If you don't customize these variable, a will be assigned automatically in respect to the Droplet hostname. The will be automatically set to the name of the default cluster.

The value is used by the auto-discovery feature of Elasticsearch to automatically discover and associate Elasticsearch nodes to a cluster. Thus, if you don't change the default value, you might have unwanted nodes, found on the same network, in your cluster.

These the minimum settings you can start with using Elasticsearch. However, it's recommended to continue reading the configuration part for more thorough understanding and fine-tuning of Elasticsearch.

More info:

Restart elasticsearch:

$ sudo systemctl start elasticsearch

Check if elasticsearch is running

curl -XGET 'localhost:9200/?pretty'

You should see output similar to below:

  "name" : "JTa9iro",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "jHEFy-V5Qgq8_V0FArNDcA",
  "version" : {
    "number" : "6.2.1",
    "build_hash" : "7299dc3",
    "build_date" : "2018-02-07T19:34:26.990113Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  "tagline" : "You Know, for Search"

4. Nextcloud configuration

Install full text search apps:

Full text search – Elasticsearch Platform (BETA) Full text search (BETA) Full text search – Files (BETA)

Config Full text search on Nextcloud

Navigate to Settings -> Full text search and set:

Full text search ->Search Platform to Elasticsearch Elastic Search -> Address of the Servlet to http://localhost:9200 Elastic Search -> Index to nextcloud

Run first index. This may take a while:

$ sudo -u www-data php /var/www/html/nextcloud/occ fulltextsearch:index



  please add ingest-attachment plugin to elasticsearch

fulltextsearch:index [--output [OUTPUT]]

1. I tried to re-install the ingest-attachment plugin:

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment

It returned another error stating that the plugin was already installled. So I just re-ran the first index again and the indexing started:

$ sudo -u www-data php /var/www/html/nextcloud/occ fulltextsearch:index



This web app has been tested on DigitalOcean. This app can also be installed using other hosts such as Amazon AWS, Google Cloud, Microsoft Azure, Vultr and others.

Installation & Maintenance

If you would like to get this app installed, maintained or need training, Contact Me to get current rates.

10 thoughts on “How To Install Full Text Search Using Elastic Search And Nextcloud

  1. >> sudo -u www-data php /var/www/html/nextcloud/occ fulltextsearch:index

    Reply is

    There are no commands defined in the “fulltextsearch” namespace.

    Installation was done via *.deb für Ubuntu 18.04 LTS headless.

    Any hint?

    1. Hello, It’s been a while since I first wrote this but the install of Full Text Search doesn’t appear to have changed much. I’m not sure what you mean by “no commands defined” as you referenced the command ending with “occ fulltextsearch:index” to initiate/run the first index. I can only reference the official github repo but I’m sure you’ve been there too. Good luck!

    2. >> sudo -u www-data php /var/www/html/nextcloud/occ fulltextsearch:index
      You have to modify the path of your installation after php in my case I have to modify it like this:
      >> sudo -u www-data php /var/www/nextcloud/occ fulltextsearch:index
      that’s because I don’t used the html folder

    1. I believe the instructions above should be enough to get Elastic Search and Nextcloud working together. I also believe that it depends on how much information/users you have in Nextcloud that will determine if you really need Elastic Search installed or not. For a “smaller” number of files, Elastic Search is not necessary at all as the default search functionality will do.

  2. Hi, does ElasticSearch fully replaces the Nextcloud Search? Technically speaking and to be specific, does it offload the database of search queries?

    Also, you don’t tak about ‘occ fulltextsearch:live’, is this necesary?


    1. ElasticSearch is used to extend the core Nextcloud fulltextsearch app. ElasticSearch will index all of your files when first installed using `./occ fulltextsearch:index` (or `sudo -u www-data php ./occ fulltextsearch:index`). ElasticSearch indexes the contents of files so it is a lot more powerful than the core fulltextsearch app which does not. `occ fulltextsearch:live` can be used if you don’t want to wait for the cron to run – so it is not really necessary but useful. You can find info on this command and the rest here: and

  3. Any suggestion how to set up fulltext search on nextcloud 23.0 with elastic 8?
    Elastic now has security enabled, with certs and https.

    Seems I cannot get fulltextsearch to find elastic.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.