Merge pull request #40618 from nextcloud/feat/39162/advanced_search
Advanced search: backend allows multiples terms to searchpull/41379/head
commit
fa761b51cc
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Search\Filter;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
class BooleanFilter implements IFilter {
|
||||
private bool $value;
|
||||
|
||||
public function __construct(string $value) {
|
||||
$this->value = match ($value) {
|
||||
'true', 'yes', 'y', '1' => true,
|
||||
'false', 'no', 'n', '0', '' => false,
|
||||
default => throw new InvalidArgumentException('Invalid boolean value '. $value),
|
||||
};
|
||||
}
|
||||
|
||||
public function get(): bool {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Search\Filter;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
class DateTimeFilter implements IFilter {
|
||||
private DateTimeImmutable $value;
|
||||
|
||||
public function __construct(string $value) {
|
||||
if (filter_var($value, FILTER_VALIDATE_INT)) {
|
||||
$value = '@'.$value;
|
||||
}
|
||||
|
||||
$this->value = new DateTimeImmutable($value);
|
||||
}
|
||||
|
||||
public function get(): DateTimeImmutable {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Search\Filter;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
class FloatFilter implements IFilter {
|
||||
private float $value;
|
||||
|
||||
public function __construct(string $value) {
|
||||
$this->value = filter_var($value, FILTER_VALIDATE_FLOAT);
|
||||
if ($this->value === false) {
|
||||
throw new InvalidArgumentException('Invalid float value '. $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): float {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Search\Filter;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\IGroup;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
class GroupFilter implements IFilter {
|
||||
private IGroup $group;
|
||||
|
||||
public function __construct(
|
||||
string $value,
|
||||
IGroupManager $groupManager,
|
||||
) {
|
||||
$this->group = $groupManager->get($value);
|
||||
if ($this->group === null) {
|
||||
throw new InvalidArgumentException('Group '.$value.' not found');
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): IGroup {
|
||||
return $this->group;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Search\Filter;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
class IntegerFilter implements IFilter {
|
||||
private int $value;
|
||||
|
||||
public function __construct(string $value) {
|
||||
$this->value = filter_var($value, FILTER_VALIDATE_INT);
|
||||
if ($this->value === false) {
|
||||
throw new InvalidArgumentException('Invalid integer value '. $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): int {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Search\Filter;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
class UserFilter implements IFilter {
|
||||
private IUser $user;
|
||||
|
||||
public function __construct(
|
||||
string $value,
|
||||
IUserManager $userManager,
|
||||
) {
|
||||
$this->user = $userManager->get($value);
|
||||
if ($this->user === null) {
|
||||
throw new InvalidArgumentException('User '.$value.' not found');
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OC\Search;
|
||||
|
||||
use Generator;
|
||||
use OCP\Search\IFilterCollection;
|
||||
use OCP\Search\IFilter;
|
||||
|
||||
/**
|
||||
* Interface for search filters
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
class FilterCollection implements IFilterCollection {
|
||||
/**
|
||||
* @var IFilter[]
|
||||
*/
|
||||
private array $filters;
|
||||
|
||||
public function __construct(IFilter ...$filters) {
|
||||
$this->filters = $filters;
|
||||
}
|
||||
|
||||
public function has(string $name): bool {
|
||||
return isset($this->filters[$name]);
|
||||
}
|
||||
|
||||
public function get(string $name): ?IFilter {
|
||||
return $this->filters[$name] ?? null;
|
||||
}
|
||||
|
||||
public function getIterator(): Generator {
|
||||
foreach ($this->filters as $k => $v) {
|
||||
yield $k => $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OC\Search;
|
||||
|
||||
use OCP\Search\FilterDefinition;
|
||||
use OCP\Search\IFilter;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use RuntimeException;
|
||||
|
||||
final class FilterFactory {
|
||||
public static function get(string $type, string|array $filter): IFilter {
|
||||
return match ($type) {
|
||||
FilterDefinition::TYPE_BOOL => new Filter\BooleanFilter($filter),
|
||||
FilterDefinition::TYPE_DATETIME => new Filter\DateTimeFilter($filter),
|
||||
FilterDefinition::TYPE_FLOAT => new Filter\FloatFilter($filter),
|
||||
FilterDefinition::TYPE_INT => new Filter\IntegerFilter($filter),
|
||||
FilterDefinition::TYPE_NC_GROUP => new Filter\GroupFilter($filter, \OC::$server->get(IGroupManager::class)),
|
||||
FilterDefinition::TYPE_NC_USER => new Filter\UserFilter($filter, \OC::$server->get(IUserManager::class)),
|
||||
FilterDefinition::TYPE_PERSON => self::getPerson($filter),
|
||||
FilterDefinition::TYPE_STRING => new Filter\StringFilter($filter),
|
||||
FilterDefinition::TYPE_STRINGS => new Filter\StringsFilter(... (array) $filter),
|
||||
default => throw new RuntimeException('Invalid filter type '. $type),
|
||||
};
|
||||
}
|
||||
|
||||
private static function getPerson(string $person): IFilter {
|
||||
$parts = explode('_', $person, 2);
|
||||
|
||||
return match (count($parts)) {
|
||||
1 => self::get(FilterDefinition::TYPE_NC_USER, $person),
|
||||
2 => self::get(... $parts),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCP\Search;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Filter definition
|
||||
*
|
||||
* Describe filter attributes
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
class FilterDefinition {
|
||||
public const TYPE_BOOL = 'bool';
|
||||
public const TYPE_INT = 'int';
|
||||
public const TYPE_FLOAT = 'float';
|
||||
public const TYPE_STRING = 'string';
|
||||
public const TYPE_STRINGS = 'strings';
|
||||
public const TYPE_DATETIME = 'datetime';
|
||||
public const TYPE_PERSON = 'person';
|
||||
public const TYPE_NC_USER = 'nc-user';
|
||||
public const TYPE_NC_GROUP = 'nc-group';
|
||||
|
||||
/**
|
||||
* Build filter definition
|
||||
*
|
||||
* @param self::TYPE_* $type
|
||||
* @param bool $exclusive If true, all providers not supporting this filter will be ignored when this filter is provided
|
||||
* @throw InvalidArgumentException in case of invalid name. Allowed characters are -, 0-9, a-z.
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function __construct(
|
||||
private string $name,
|
||||
private string $type = self::TYPE_STRING,
|
||||
private bool $exclusive = true,
|
||||
) {
|
||||
if (!preg_match('/[-0-9a-z]+/Au', $name)) {
|
||||
throw new InvalidArgumentException('Invalid filter name. Allowed characters are [-0-9a-z]');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter name
|
||||
*
|
||||
* Name is used in query string and for advanced syntax `name: <value>`
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function name(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter type
|
||||
*
|
||||
* Expected type of value for the filter
|
||||
*
|
||||
* @return self::TYPE_*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function type(): string {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is filter exclusive?
|
||||
*
|
||||
* If exclusive, only provider with support for this filter will receive the query.
|
||||
* Example: if an exclusive filter `mimetype` is declared, a search with this term will not
|
||||
* be send to providers like `settings` that doesn't support it.
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function exclusive(): bool {
|
||||
return $this->exclusive;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCP\Search;
|
||||
|
||||
/**
|
||||
* Interface for search filters
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
interface IFilter {
|
||||
/**
|
||||
* Get filter value
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function get(): mixed;
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCP\Search;
|
||||
|
||||
use IteratorAggregate;
|
||||
|
||||
/**
|
||||
* Interface for search filters
|
||||
*
|
||||
* @since 28.0.0
|
||||
* @extends IteratorAggregate<string, \OCP\Search\IFilter>
|
||||
*/
|
||||
interface IFilterCollection extends IteratorAggregate {
|
||||
/**
|
||||
* Check if a filter exits
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function has(string $name): bool;
|
||||
|
||||
/**
|
||||
* Get a filter by name
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function get(string $name): ?IFilter;
|
||||
|
||||
/**
|
||||
* Return Iterator of filters
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function getIterator(): \Traversable;
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCP\Search;
|
||||
|
||||
/**
|
||||
* Interface for advanced search providers
|
||||
*
|
||||
* These providers will be implemented in apps, so they can participate in the
|
||||
* global search results of Nextcloud. If an app provides more than one type of
|
||||
* resource, e.g. contacts and address books in Nextcloud Contacts, it should
|
||||
* register one provider per group.
|
||||
*
|
||||
* @since 28.0.0
|
||||
*/
|
||||
interface IFilteringProvider extends IProvider {
|
||||
/**
|
||||
* Return the names of filters supported by the application
|
||||
*
|
||||
* If a filter sent by client is not in this list,
|
||||
* the current provider will be ignored.
|
||||
* Example:
|
||||
* array('term', 'since', 'custom-filter');
|
||||
*
|
||||
* @since 28.0.0
|
||||
* @return string[] Name of supported filters (default or defined by application)
|
||||
*/
|
||||
public function getSupportedFilters(): array;
|
||||
|
||||
/**
|
||||
* Get alternate IDs handled by this provider
|
||||
*
|
||||
* A search provider can complete results from other search providers.
|
||||
* For example, files and full-text-search can search in files.
|
||||
* If you use `in:files` in a search, provider files will be invoked,
|
||||
* with all other providers declaring `files` in this method
|
||||
*
|
||||
* @since 28.0.0
|
||||
* @return string[] IDs
|
||||
*/
|
||||
public function getAlternateIds(): array;
|
||||
|
||||
/**
|
||||
* Allows application to declare custom filters
|
||||
*
|
||||
* @since 28.0.0
|
||||
* @return list<FilterDefinition>
|
||||
*/
|
||||
public function getCustomFilters(): array;
|
||||
}
|
||||
Loading…
Reference in New Issue