Skip to content

Commit 2e9c4c4

Browse files
authored
Merge pull request #177 from ConductionNL/development
Development to main
2 parents f24d9fd + 9728683 commit 2e9c4c4

File tree

6 files changed

+395
-162
lines changed

6 files changed

+395
-162
lines changed

docs/fulltextsearch.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Full Text Search NextCloud App(s)
2+
3+
## Overview
4+
5+
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.
6+
7+
## Local Setup Steps
8+
9+
1. Open a command-line interface (CLI), such as:
10+
- **Windows:** Command Prompt (`cmd`), PowerShell, or Windows Terminal.
11+
- **Linux/macOS:** Terminal.
12+
2. Navigate to your local Nextcloud repository (where a docker-compose.yml file is present):
13+
```sh
14+
cd {route to your local NC repo}
15+
```
16+
3. Start the necessary Docker containers:
17+
```sh
18+
docker-compose up nextcloud proxy elasticsearch
19+
```
20+
4. In the Nextcloud front-end, go to **NC Apps > Search** and install the following three apps:
21+
- **Full text search Files**
22+
- **Full text search Elastic**
23+
- **Full text search**
24+
5. Under **Administrator settings**, go to **Full text search** in the sidebar.
25+
6. Under **General**, configure the following:
26+
- **Search Platform:** Set to **"Elasticsearch"**.
27+
- **Navigation Icon:** Check this option.
28+
7. Under **Elastic Search**, set the following:
29+
- **Address of the Servlet:**
30+
```
31+
http://elastic:elastic@elasticsearch:9200
32+
```
33+
- **Index:**
34+
```
35+
my_index
36+
```
37+
- **[Advanced] Analyzer tokenizer:**
38+
```
39+
standard
40+
```
41+
8. Under **Files**, configure the following
42+
- **Check all checkboxes:**
43+
- Local Files
44+
- Group Folders
45+
- Extract PDF
46+
- Extract Office & Open Files
47+
- **Maximum file size:** Set your prefered maximum file size (at least **64** is recommended).
48+
9. Add some files to Nextcloud in the Files tab of NextCloud.
49+
10. Run the indexing command in the `master-nextcloud-1` container in Docker Desktop:
50+
```sh
51+
sudo -u www-data php ./occ fulltextsearch:index
52+
```
53+
11. Open the **search app** and search for files based on the text inside them.
54+
55+
## More Information
56+
57+
If you need more details or troubleshooting help, you can refer to the following resources:
58+
59+
- [Nextcloud Full Text Search Wiki - Basic Installation](https://github.com/nextcloud/fulltextsearch/wiki/Basic-Installation)
60+
- [Nextcloud Docker Development - Full Text Search](https://juliusknorr.github.io/nextcloud-docker-dev/services/more/#fulltextsearch)
61+
- [YouTube Guide on Full Text Search for Nextcloud](https://www.youtube.com/watch?v=yPZkrzgue5c)
62+
63+
These resources provide in-depth explanations, configurations, and troubleshooting tips.

docs/image.png

154 KB
Loading

lib/Db/ObjectEntity.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
use OCP\AppFramework\Db\Entity;
88
use OCP\IUserSession;
99

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

34+
/**
35+
* Initialize the entity and define field types
36+
*/
2837
public function __construct() {
2938
$this->addType(fieldName:'uuid', type: 'string');
3039
$this->addType(fieldName:'uri', type: 'string');
@@ -43,6 +52,11 @@ public function __construct() {
4352
$this->addType(fieldName:'folder', type: 'string');
4453
}
4554

55+
/**
56+
* Get array of field names that are JSON type
57+
*
58+
* @return array List of field names that are JSON type
59+
*/
4660
public function getJsonFields(): array
4761
{
4862
return array_keys(
@@ -52,6 +66,12 @@ public function getJsonFields(): array
5266
);
5367
}
5468

69+
/**
70+
* Hydrate the entity from an array of data
71+
*
72+
* @param array $object Array of data to hydrate the entity with
73+
* @return self Returns the hydrated entity
74+
*/
5575
public function hydrate(array $object): self
5676
{
5777
$jsonFields = $this->getJsonFields();
@@ -76,12 +96,30 @@ public function hydrate(array $object): self
7696
return $this;
7797
}
7898

79-
99+
/**
100+
* Serialize the entity to JSON format
101+
*
102+
* Creates a metadata array containing object properties except sensitive fields.
103+
* Filters out 'object', 'textRepresentation' and 'authorization' fields and
104+
* stores remaining properties under '@self' key for API responses.
105+
*
106+
* @return array Serialized object data
107+
*/
80108
public function jsonSerialize(): array
81109
{
82-
return $this->object;
110+
$metadata = [
111+
'@self' => array_filter($this->getObjectArray(), function($key) {
112+
return in_array($key, ['object', 'textRepresentation', 'authorization']) === false;
113+
}, ARRAY_FILTER_USE_KEY)
114+
];
115+
return array_merge($metadata, $this->object);
83116
}
84117

118+
/**
119+
* Get array representation of all object properties
120+
*
121+
* @return array Array containing all object properties
122+
*/
85123
public function getObjectArray(): array
86124
{
87125
return [

0 commit comments

Comments
 (0)