Commit Graph

338 Commits

Author SHA1 Message Date
Dominik Schmidt
1b697e4001 refactor(search): run the OpenSearch backend on the shared lowering pass
KQLToOpenSearchBoolQuery runs query.Normalize, then only value lowercasing stays
backend-specific; remapKey and unfoldValue are gone.
2026-07-29 17:44:42 +02:00
Dominik Schmidt
330d2f3a31 refactor(search): run the bleve backend on the shared lowering pass
The bleve Creator runs query.Normalize before compiling; the compiler consumes a
canonical AST with no field resolution or media-type special-casing.
2026-07-29 17:44:42 +02:00
Dominik Schmidt
e1c634e546 feat(search): add shared KQL lowering pass
query.Normalize resolves field names (query.ResolveField, from the derived
index + a small alias overlay) and expands media-type restrictions
(mimetype.Expand) once, between parse and backend compilation.
2026-07-29 17:44:41 +02:00
Dominik Schmidt
1a4daf38bf feat(search): derive a case-insensitive field-name index from the resource struct
mapping.FieldNameIndex walks the struct and maps a lowercased field path to the
real field name, including nested facet sub-fields. Backend-neutral.
2026-07-29 17:43:29 +02:00
Dominik Schmidt
991d36d5ad refactor(kql): move parse/validation errors into pkg/kql
The KQL parser produced its own validation errors but imported them from the
search service's query package. Move them into pkg/kql and let the search
backend consume kql.IsValidationError, so the parser stops depending on a
service package.
2026-07-29 17:39:23 +02:00
Dominik Schmidt
54f0d80e02 fix(search): preserve query value case for case-sensitive fields on OpenSearch
OpenSearch lowercased every KQL query value, so exact-match queries on
case-preserved keyword fields (facet values, ids) never matched their stored
token. Fold the value only for fields with a lowercasing analyzer, mirroring the
bleve backend. The field set is derived once in search.LowercaseValueFields and
shared by both backends (bleve's local buildLowercaseFields is dropped).
2026-07-29 16:39:30 +02:00
Dominik Schmidt
831f8cf773 feat(search): version the search index by schema version
Both backends carry a shared search.SchemaVersion in the index name
(OpenSearch <base>-vN) and data path (bleve-vN). A breaking schema change
bumps the version so the service builds a fresh index instead of colliding
with the incompatible previous one; the old index is left in place.
2026-07-28 19:50:25 +02:00
Dominik Schmidt
429a9c03da fix(search): type mtime as a date 2026-07-16 02:21:57 +02:00
Dominik Schmidt
599022e40f test(search): set Mtime on opensearch folder and root fixtures
The Mtime field is mapped as an OpenSearch `date`, which rejects an
empty value with `mapper_parsing_exception: cannot parse empty date`.
The folder and root fixtures had no Mtime, so serializing them to
`"Mtime": ""` made TestEngine_Purge/purge_resource_trees fail when the
document was indexed. Give both a valid RFC3339 Mtime, matching the
file fixture.
2026-07-06 16:30:24 +02:00
Dominik Schmidt
431c97e712 test(search): convert mapping package tests to ginkgo
New package, so use the repo's standard test framework.
2026-07-05 16:56:10 +02:00
Dominik Schmidt
22f46dd9d4 test(search): convert bleve geo/mtime tests to ginkgo
The package's engine suite is ginkgo; these new tests were plain.
2026-07-05 16:56:10 +02:00
Dominik Schmidt
9ebf755cfd test(search): use RFC3339 Mtime in opensearch fixture
Mtime is now a date field; the fixture's Go-format string fails
OpenSearch date parsing.
2026-07-05 16:56:10 +02:00
Dominik Schmidt
00468734f6 feat(search): index Location as a geopoint on both backends
Add a TypeGeopoint field type. The libregraph Location facet is kept as an
object (retrieval / numeric queries) and a sibling <name>_geopoint field
carries the {lat,lon} form for geo-distance / bbox / polygon queries,
uniform across bleve and OpenSearch via the shared mapping. PrepareForIndex
splices the sibling in at write time.
2026-07-02 16:05:49 +02:00
Dominik Schmidt
ac86d9b907 refactor: reflection-based search mapping
Build the bleve and OpenSearch index mappings from the Go struct via
reflection (json tags + per-field overrides) instead of hand-rolled
mappings and hit deserializers. New mapping package: BleveBuildMapping,
OpenSearchBuildMapping, Deserialize[T], PrepareForIndex; field decoding is
fail-soft. Mtime is typed as a date so mtime ranges are chronological on
both backends. Route CS3 facet parsing through mapping.DeserializeStringMap.

The any-valued (bleve hit) and string-valued (CS3 metadata) deserializers
share one generic fillStruct walker with a per-value setLeaf callback.
2026-07-02 16:04:46 +02:00
Jörn Friedrich Dreyer
81fd00043e Merge pull request #2063 from opencloud-eu/nats-tls-options
add tls support for all nats connections
2026-06-16 13:21:22 +02:00
Christian Richter
faf3ff1959 change error level for trashing items interaction with search
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
2026-06-15 10:39:23 +02:00
Jörn Friedrich Dreyer
77fd4fca69 add tls support for all nats connections
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-06-10 17:04:18 +02:00
Jörn Friedrich Dreyer
2b1c4fe300 index command: allow passing insecure flag
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-05-13 14:00:19 +02:00
Jörn Friedrich Dreyer
5854b602f1 make search index cli use grpc client
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-05-13 11:56:41 +02:00
Michael Barz
b4788ca45a fix: cleaner debounce timer test 2026-05-12 08:46:33 +02:00
Florian Schade
32dd087b59 Merge pull request #2701 from opencloud-eu/typo-in-opensearch-error-message
fix: remove typo in error message
2026-05-06 09:38:21 +02:00
Dominik Schmidt
30d74f74bf Merge pull request #2633 from opencloud-eu/fix/search-preserve-value-case
fix(search): preserve value case for non-lowercased bleve fields
2026-05-05 12:35:54 +02:00
Thomas Schweiger
c9887c17cf fix: remove typo in error message 2026-04-30 13:13:20 +02:00
Jörn Friedrich Dreyer
2d1cc3fb3a stop metrics tickers on context cancel
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-04-28 16:18:45 +02:00
André Duffeck
e9e195789d Adapt to changes in reva/cs3apis 2026-04-24 14:49:11 +02:00
Florian Schade
d0e3f14539 chore: remove loop var references 2026-04-23 17:11:55 +02:00
Florian Schade
288e67cc39 chore: replace interface with any 2026-04-23 09:31:11 +02:00
Dominik Schmidt
365bd94418 refactor(search): use map[string]struct{} for lowercaseFields set
Bring the membership lookup in line with the existing repo convention
for set types (see services/thumbnails/pkg/thumbnail/mimetypes.go for
the same pattern). Storing struct{} values instead of bool makes the
set semantics explicit and rules out accidental false entries.
2026-04-22 10:01:02 +02:00
Dominik Schmidt
87b1f6f630 test(search): cover audio.artist instead of Title for case preservation
The FIXME pointed at #2632 (dotted keys in KQL property restrictions),
which is now merged. Use audio.artist — the originally intended target
field for this regression — so the test matches its name: a nested
string field that is not on the lowercase allowlist.
2026-04-22 09:51:37 +02:00
Dominik Schmidt
796e5fd373 fix(search): tighten lowercaseFields comment
Copilot review pointed out that the comment claimed pre-lowercasing
makes non-analyzed query types (wildcard, fuzzy) match for every
allowlisted field. That is true for Name/Tags/Favorites, whose
lowercaseKeyword analyzer emits a single lowercased token, but the
Content analyzer also stems terms — so the guarantee doesn't hold
there. Drop the specific claim and keep the comment to the intent:
stay consistent with the field's analyzer.
2026-04-22 09:50:19 +02:00
Dominik Schmidt
538c82787c fix(search): preserve value case for non-lowercased bleve fields
The bleve compiler lowercased every query value (except Hidden)
before handing it to the engine. This matched the index tokens
for fields whose analyzer folds case — Name, Tags, Favorites,
Content — but silently broke matching for every other field,
whose default keyword analyzer preserves case. A query like
Title:"Some Title" parsed fine, lowercased to "some title", and
missed the indexed token "Some Title".

Replace the blanket lowercasing with an allowlist of the four
fields whose index mapping actually uses a lowercasing analyzer.
Every other field now passes through unchanged, which keeps
values like "deadmau5" or "Motörhead" intact instead of
normalising them to a case the tag writer didn't choose.
2026-04-22 09:50:19 +02:00
Dominik Schmidt
15d779cb23 refactor(search): rename forceReindexFlag to forceRescanFlag
Address review feedback: now that the flag is read under its
registered name `force-rescan`, line the local variable up with the
operator-facing vocabulary. The proto field `ForceReindex` is left
untouched so the wire format stays the same.
2026-04-21 15:29:04 +02:00
Dominik Schmidt
e7806445dc fix(search): read --force-rescan flag with its registered name
The `opencloud search index` command registers the flag as
`--force-rescan` (see pflag registration below) but reads it via
`GetBool("force-reindex")`, so the value is always false — passing
`--force-rescan` had no effect and no force rescan was ever triggered.

Read the flag under its registered name.
2026-04-21 15:29:04 +02:00
Dominik Schmidt
2fc33d6e60 refactor(search): round xmpDM:duration to the nearest millisecond
Address review feedback: a straight int64 cast truncates toward zero,
so Tika values that produce results like 1234.999... millisecond would
land at 1234 ms instead of 1235 ms. Round before casting so durations
are as accurate as float64 allows.
2026-04-21 15:16:57 +02:00
Dominik Schmidt
3c59935012 fix(search): parse tika xmpDM:duration as a float
Tika emits xmpDM:duration as seconds in floating-point form (for
example "154.57379150390625"), so strconv.ParseInt rejected every
value and the field was silently dropped — every indexed audio item
ended up without a duration.

Parse the value with strconv.ParseFloat and convert to milliseconds
ourselves. Adjust the existing extractor test to cover the fractional
case.
2026-04-21 15:16:57 +02:00
André Duffeck
bcdfbda08d Fix test 2026-04-14 08:20:28 +02:00
André Duffeck
60bcc6b0f2 Add a flag to the reindex command to force a full reindex
That can be helpful when the search service configuration has changed,
e.g. by enabling TIKA. Previously files that had already been indexed
were not indexed again and thus were no part of the fulltext index.

Fixes #2285
Fixes #2578
2026-04-14 08:20:28 +02:00
André Duffeck
71c0a469b9 Reduce default batch size to prevent memory issues with large documents 2026-03-25 14:27:37 +01:00
André Duffeck
428f69416f Commit batches when the limit is reached while iterating over children 2026-03-25 14:27:37 +01:00
André Duffeck
dea306247b Do not remove stopwords by default
Keeping the stop words leads to slightly bigger indexes but fixes
chopped up highlights of search results and phrase accuracy during
search.
2026-03-25 09:41:23 +01:00
André Duffeck
8a83eea742 Limit the highlighter to two fragments 2026-03-25 08:41:48 +01:00
André Duffeck
4fa5198501 Improve highlight support in osu
Co-authored-by: Florian Schade <f.schade@icloud.com>
2026-03-25 08:41:48 +01:00
André Duffeck
a6dd9b9e18 Use the fast vector highlighter for highlighting search results 2026-03-25 08:41:48 +01:00
André Duffeck
9e93f29ffe Introduce opensearch index v2
The new index allows for faster highlighing uses the fvh highlighter and
searching for favorites.
2026-03-25 08:41:48 +01:00
André Duffeck
10bc14130e Do not send back the full content in the search response 2026-03-23 13:52:09 +01:00
André Duffeck
cd0831aa10 We no longer manage favorites via arbitrary metadata 2026-03-13 09:38:28 +01:00
André Duffeck
d214a7535c Make the search index pick up changes to favorites 2026-03-13 09:38:28 +01:00
André Duffeck
ce5ec1b3dc Add support for favorites to the search service 2026-03-13 09:38:28 +01:00
Christian Richter
f7caf637ce consolidate log config in search
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
2026-01-08 13:18:45 +01:00
Jörn Friedrich Dreyer
d0e51010bf replace more .Value.String() occurences
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-12-15 16:40:27 +01:00