Skip to content

feat: specify portions of document to be passed from platform to provider - #960

Open
madbob wants to merge 1 commit into
nextcloud:masterfrom
madbob:body_portions
Open

feat: specify portions of document to be passed from platform to provider#960
madbob wants to merge 1 commit into
nextcloud:masterfrom
madbob:body_portions

Conversation

@madbob

@madbob madbob commented Aug 1, 2026

Copy link
Copy Markdown

Right now, FTS platform fulltextsearch_elasticsearch returns an arbitrary set of data among those stored in the index, ignoring tags, subtags, metatags and more (pun intended).

It is fine to no fetch and pass everything all the time, but sometime a provider may find convenient to just reuse data already attached to a document instead of retrieve all of them from scratch.

Use case: I'm hacking a FTS provider for mail, and I have lots of structured data to index, to filter in search requests (e.g. from: filters), and to use while displaying the response (e.g. from can be used to retrieve the avatar of the message sender). Retrieve all of them again from the database (or, even worse: from the IMAP server) for each search result may become a bit inefficient.

Rationale of this proposal is to provide a method for the provider to specify (eventually in own implementation of IFullTextSearchProvider::improveSearchRequest()) the list of parts required back from the platform. A mere list of strings in SearchRequest, meant to be read and handled from the platform.

Sample implied implementation of changes in SearchMappingService::generateSearchQueryParams() (here):

$params = [
	'index' => $this->configService->getElasticIndex(),
	'size' => $request->getSize(),
	'from' => (($request->getPage() - 1) * $request->getSize()),
	'_source_excludes' => 'content',
	'_source_includes' => join(',', $request->getPortions()),   // <----- this line!
];

and SearchService::parseSearchEntry() also would require some adjustment (which I can provide myself if this is approved!).

Comment thread lib/Model/SearchRequest.php Outdated
Comment on lines +698 to +702
/**
* @param BodyPortion $query
*
* @return ISearchRequest
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @param BodyPortion $query
*
* @return ISearchRequest
*/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to completely remove this comment? It is not useful, just as all other doc comment in this class...

Comment thread lib/Model/SearchRequest.php Outdated
Comment thread lib/Tools/Enums/BodyPortion.php Outdated

namespace OCA\FullTextSearch\Tools\Enums;

enum BodyPortion: string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this belong to https://github.com/nextcloud/server/tree/master/lib/public/FullTextSearch/Model and the addPortion and getPortions in the ISearchRequest interface also in server

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to nextcloud/server#62903

…ider

Signed-off-by: Roberto Guido <info@madbob.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants