Skip to content

Commit

Permalink
Merge pull request #177 from ConductionNL/development
Browse files Browse the repository at this point in the history
Development to main
  • Loading branch information
rubenvdlinde authored Feb 12, 2025
2 parents f24d9fd + 9728683 commit 2e9c4c4
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 162 deletions.
63 changes: 63 additions & 0 deletions docs/fulltextsearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Full Text Search NextCloud App(s)

## Overview

This document provides some information about the NextCloud Full Text Search App(s) and a step-by-step plan how to set this up on your local machine with the use of ElasticSearch as search platform.

## Local Setup Steps

1. Open a command-line interface (CLI), such as:
- **Windows:** Command Prompt (`cmd`), PowerShell, or Windows Terminal.
- **Linux/macOS:** Terminal.
2. Navigate to your local Nextcloud repository (where a docker-compose.yml file is present):
```sh
cd {route to your local NC repo}
```
3. Start the necessary Docker containers:
```sh
docker-compose up nextcloud proxy elasticsearch
```
4. In the Nextcloud front-end, go to **NC Apps > Search** and install the following three apps:
- **Full text search Files**
- **Full text search Elastic**
- **Full text search**
5. Under **Administrator settings**, go to **Full text search** in the sidebar.
6. Under **General**, configure the following:
- **Search Platform:** Set to **"Elasticsearch"**.
- **Navigation Icon:** Check this option.
7. Under **Elastic Search**, set the following:
- **Address of the Servlet:**
```
http://elastic:elastic@elasticsearch:9200
```
- **Index:**
```
my_index
```
- **[Advanced] Analyzer tokenizer:**
```
standard
```
8. Under **Files**, configure the following
- **Check all checkboxes:**
- Local Files
- Group Folders
- Extract PDF
- Extract Office & Open Files
- **Maximum file size:** Set your prefered maximum file size (at least **64** is recommended).
9. Add some files to Nextcloud in the Files tab of NextCloud.
10. Run the indexing command in the `master-nextcloud-1` container in Docker Desktop:
```sh
sudo -u www-data php ./occ fulltextsearch:index
```
11. Open the **search app** and search for files based on the text inside them.

## More Information

If you need more details or troubleshooting help, you can refer to the following resources:

- [Nextcloud Full Text Search Wiki - Basic Installation](https://github.com/nextcloud/fulltextsearch/wiki/Basic-Installation)
- [Nextcloud Docker Development - Full Text Search](https://juliusknorr.github.io/nextcloud-docker-dev/services/more/#fulltextsearch)
- [YouTube Guide on Full Text Search for Nextcloud](https://www.youtube.com/watch?v=yPZkrzgue5c)

These resources provide in-depth explanations, configurations, and troubleshooting tips.
Binary file added docs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 40 additions & 2 deletions lib/Db/ObjectEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
use OCP\AppFramework\Db\Entity;
use OCP\IUserSession;

/**
* Entity class representing an object in the OpenRegister system
*
* This class handles storage and manipulation of objects including their metadata,
* locking mechanisms, and serialization for API responses.
*/
class ObjectEntity extends Entity implements JsonSerializable
{
protected ?string $uuid = null;
Expand All @@ -25,6 +31,9 @@ class ObjectEntity extends Entity implements JsonSerializable
protected ?DateTime $created = null;
protected ?string $folder = null; // The folder path where this object is stored

/**
* Initialize the entity and define field types
*/
public function __construct() {
$this->addType(fieldName:'uuid', type: 'string');
$this->addType(fieldName:'uri', type: 'string');
Expand All @@ -43,6 +52,11 @@ public function __construct() {
$this->addType(fieldName:'folder', type: 'string');
}

/**
* Get array of field names that are JSON type
*
* @return array List of field names that are JSON type
*/
public function getJsonFields(): array
{
return array_keys(
Expand All @@ -52,6 +66,12 @@ public function getJsonFields(): array
);
}

/**
* Hydrate the entity from an array of data
*
* @param array $object Array of data to hydrate the entity with
* @return self Returns the hydrated entity
*/
public function hydrate(array $object): self
{
$jsonFields = $this->getJsonFields();
Expand All @@ -76,12 +96,30 @@ public function hydrate(array $object): self
return $this;
}


/**
* Serialize the entity to JSON format
*
* Creates a metadata array containing object properties except sensitive fields.
* Filters out 'object', 'textRepresentation' and 'authorization' fields and
* stores remaining properties under '@self' key for API responses.
*
* @return array Serialized object data
*/
public function jsonSerialize(): array
{
return $this->object;
$metadata = [
'@self' => array_filter($this->getObjectArray(), function($key) {
return in_array($key, ['object', 'textRepresentation', 'authorization']) === false;
}, ARRAY_FILTER_USE_KEY)
];
return array_merge($metadata, $this->object);
}

/**
* Get array representation of all object properties
*
* @return array Array containing all object properties
*/
public function getObjectArray(): array
{
return [
Expand Down
Loading

0 comments on commit 2e9c4c4

Please sign in to comment.