Install and configure FullTextSearch + Elasticsearch using occ / command line

I can’t seem to find any details for configuring the Fulltextsearch and Elasticsearch plugins after successfully installing them. I have no problem installing/enabling the plugins using occ app:enable ..., but after that it seems I have to manually set up the Elasticsearch plugin using the GUI.

I tried to do exactly that in the hopes I could then dig the settings out of the config.php but the plugins don’t seem to store any config settings there.

I’ve found a list of available commands HERE, but they don’t include anything for configuration, only operating the feature once it’s been installed and configured.

Does anyone know if you can enable the elasticsearch Platform, and point NC fulltextsearch at it using OCC?


EDIT: I’ve found a number of related values in the Database -> oc_appconfig table…

fulltextsearch			app_navigation		1
fulltextsearch			enabled			yes
fulltextsearch			installed_version	1.4.1
fulltextsearch			provider_indexed	{"test_provider":"0"}
fulltextsearch			search_platform		OCA\FullTextSearch_ElasticSearch\Platform\ElasticSearchPlatform
fulltextsearch			types	
fulltextsearch_elasticsearch	analyzer_tokenizer	standard
fulltextsearch_elasticsearch	elastic_host		http://localhost:9200
fulltextsearch_elasticsearch	elastic_index		nextcloud
fulltextsearch_elasticsearch	enabled	yes
fulltextsearch_elasticsearch	installed_version	1.5.1
fulltextsearch_elasticsearch	types	

Is there a way to inject these settings during setup using OCC or another built-in feature, or can I simply use mysql statements to add/update these… and is that wise?

Thanks,
Kevin.

Little more searching and I found the occ commands I was looking for. The following will import a json array of settings:

occ config:import /tmp/settings.json

The json file has the following syntax…

{
    "apps": {
        "fulltextsearch": {
            "app_navigation": "1",
            "enabled": "yes",
            "search_platform": "OCA\\FullTextSearch_ElasticSearch\\Platform\\ElasticSearchPlatform",
            "types": ""
        },
        "fulltextsearch_elasticsearch": {
            "analyzer_tokenizer": "standard",
            "elastic_host": "http://localhost:9200",
            "elastic_index": "nextcloud",
            "enabled": "yes",
            "types": ""
        }
    }
}

Hope that helps someone else!

Production server NC 19 via snap, Elasticsearch added

all checks in NC OK, querying Elasticsearch returns correct result, queries in NC only return files with search string as part of filename

I then setup a fresh installation with Ubuntu server und Nextcloud being installed with system setup (also using snap). Added Elasticsearch - everything works as expected, i.e. search in NV returns file with search string being part of content.

I then extracted configuration data with

sudo nextcloud.occ config:list > config-list.txt

and compared the files of my two installations.

What I found was

"fulltextsearch": {
        "app_navigation": "1",
        "cron_err_reset": "1598114208",
        "enabled": "yes",
        "installed_version": "1.4.2",
        "provider_indexed": "{\"deck\":\"1\",\"files\":\"1\"}",
        "search_platform": "OCA\\FullTextSearch_ElasticSearch\\Platform\\ElasticSearchPlatform",
        "types": ""
    }

on the working server. On the failing server one line is different

	"provider_indexed": "{\"deck\":\"1\"}",

I now suspect that this maybe the reason for my problems.

Deleting the NC apps and reinstalling them did not help. Re-indexing files via

sudo nextcloud.occ fulltextsearch:index --no-readline

did not help.

So I came up with what is described in Install and configure FullTextSearch + Elasticsearch using occ / command line.

But that command fails with “The file must contain a valid json array”.

I suspect that the JSON data showed there should be inside

“system”: {}

Someone here to comment on that?

Where can I find more information regarding configuration via OCC, especially search? I did see the docs on Github, but regarding search that was not as specific as required. And reading PHP code is not my business, sorry.

Greetings Wolfgang

I have a similar issue after installing Full Text Search apps and running occ to start and run first index. It still doesn’t find contents of files when searched, only if search string is in file name does it return a result. I too ran sudo -u www-data php occ config:list > config-list.txt and the difference between mine and yours that you show above is this:
“provider_indexed”: “{"test_provider":"0"}”,

I’m not sure why mine shows “test provider”.

Have you learned anything new? Does anyone else reading this know more about this issue? Thank you.

Tried again today. I still get error “The file must contain a valid json array”. JSON file contains valid JSON data as checked with https://jsonformatter.org/.

@oucil Any idea why JSON fails? I tried several versions with and without including “system”: { … }.

As an example:

{
“system”: {
“fulltextsearch”: {
“app_navigation”: “1”,
“enabled”: “yes”,
“installed_version”: “1.4.2”,
“provider_indexed”: “{“deck”:“1”,“files”:“1”}”,
“search_platform”: “OCA\FullTextSearch_ElasticSearch\Platform\ElasticSearchPlatform”,
“types”: “”
}
}
}

Hello Any updates as I’m facing the same issues

I’ve managed to set it with a series of occ config:app:set calls.
For the fulltextsearch these look like this:

occ config:app:set fulltextsearch app_navigation --value="1"
occ config:app:set fulltextsearch enabled --value="yes"
occ config:app:set fulltextsearch search_platform --value="OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform"
occ config:app:set fulltextsearch types --value=""

for the elastic search:

occ config:app:set fulltextsearch_elasticsearch analyzer_tokenizer --value=""
occ config:app:set fulltextsearch_elasticsearch analyzer_tokenizer --value="standard"
occ config:app:set fulltextsearch_elasticsearch elastic_host --value="http://localhost:9200"
occ config:app:set fulltextsearch_elasticsearch elastic_index --value="nextcloud"
occ config:app:set fulltextsearch_elasticsearch enabled --value="yes"
occ config:app:set fulltextsearch_elasticsearch types --value="

Read the current settings with occ config:list | less

Test the fulltextsearch settings with:

occ fulltextsearch:check
occ fulltextsearch:test