The search_elastic app adds a full text search for files stored in ownCloud. It requires an elasticsearch server and can index all fitles supported by apache tika, eg. plain text, .docx, .xlsx, .pptx, .odt, .ods and .pdf files. The source code is available on GitHub
Elasticsearch 6 is not yet supported
search_elastic requires ingest-attachment processor to be present
$ cd /usr/share/elasticsearch/
$ bin/elasticsearch-plugin install ingest-attachment
$ service elasticsearch restart
Or, if you used the tarball:
$ cd /path/to/unzipped/tar
$ bin/elasticsearch-plugin install ingest-attachment
$ bin/elasticsearch
To have a elastic-search running locally, use docker-compose -f tests/docker-compose.yml up .
It will build an image with the ingest-attachment plugin available and expose elasticseach locally at port 9200/9300
Elasticsearch 2.x is only supported in app versions up to 0.2.5.
To trigger indexing create, upload or change a file. The next cron.php will index all unindexed files for the user who did the change.
After enabling the app it will be in active mode
To do an initial full indexing, without the app interfering it can be put in passive mode with
# sudo -u www-data ./occ config:app:set search_elastic mode --value passive
# sudo -u www-data ./occ config:app:set search_elastic mode --value active
It is possible to limit the users that will have access to full text search by setting a group eg. to 'admin' with
# sudo -u www-data php occ config:app:set search_elastic group --value admin
This will cause only members of the admin group to do a full text search. If you want the index to be built subsequently in active mode use a group that no user is a member of or that des not exist, eg. 'nobody'. If you leave the group empty every user will be able to use the app. This functionality also allows you to provide full text search as an added value eg for the 'premium' users.
If you only want to use search_elastic as a more scalable search on
filenames you can disable content indexing by setting nocontent to
true (default is false):
# sudo -u www-data php occ config:app:set search_elastic nocontent --value true
Note that you will have to reindex all files if you change this back to
false. Setting it to true does not require reindexing. Nevertheless,
go with limiting full text search to certain groups, by setting
group.nocontent which is more flexible anyway.
If you only want to use the search in shared filenames you can disable
full text search for a specific group by setting group.nocontent to the
group whose users should only receive results based on filenames (not the
full path), eg. users in group 'nofulltext':
# sudo -u www-data php occ config:app:set search_elastic group.nocontent --value nofulltext
You can also configure multiple groups by separating them with comma:
# sudo -u www-data php occ config:app:set search_elastic group.nocontent --value nofulltext,anothergroup,"group with blanks"
This allows a scalable search in shared files without clouding the results with content based hits.
Create a search index from scratch. Use it for a single user by entering the username as an argument. Use --all to run it for all users.
# sudo -u www-data php occ search:index:create --all
Indexing user admin
Indexing user user1
Indexing user user2
...
This should be used to index all files for the first time. It doesn't update changes to the metadata correctly, if you run it multiple times.
Updates to the search index due to changed content or changed metadata are happening via background jobs that are added to a queue. These background jobs are normally run by the ownCloud cronjob. Use this command to run the background jobs more often.
# sudo -u www-data php occ search:index:update
Reset an index. Needs to be run once before first indexing. Use the --force option to skip further warning messages.
# sudo -u www-data php occ search:index:reset --force
Reset an index for a single user and recreate it from scratch. Use the --force option to skip further warning messages.
# sudo -u www-data php occ search:index:rebuild USERID --force
There are two ways to trigger the indexing of a file. Either you do it immediately after a file is written to (in sync) or you make a note that the file changed and do it later (asynchronous). The former makes sure that the files and the index remain consistent. The latter will eventually reach consistency and has significant benefits:
When you recently edited a file, chances are that you still know where it resides and won't use the search to find it.
Content type
Image
Digest
Size
296.1 MB
Last updated
almost 7 years ago
docker pull rbrayner/owncloud-elasticsearch