HumHub Documentation (unofficial)

SearchQuery
in package

Boolean search query

Parses a given search query into relevant terms.

Examples:

  • Apple Banana, +Apple +Banana
  • "Apple pie" "Banana bread"
  • Apple NOT Banana, Apple -Banana
Tags
since
1.16

Table of Contents

Properties

$notTerms  : array<string|int, string>
All terms which should excluded, with NOT or - operator
$terms  : array<string|int, string>
All terms which are required, without operator or with AND or + operator

Methods

__construct()  : mixed
addNotTerm()  : mixed
addTerm()  : mixed
isNotTerm()  : bool
isPhrase()  : bool
parseQuery()  : array<string|int, mixed>
prepareTerm()  : string|null
Prepare a term before using

Properties

$notTerms

All terms which should excluded, with NOT or - operator

public array<string|int, string> $notTerms = []

Keyword samples how they are stored here: 'NOT Apple' => ['Apple*'] '-Apple' => ['Apple*'] 'NOT "Apple"' => ['Apple'] '-"Apple"' => ['Apple'] '-"Apple Banana"' => ['Apple Banana'] '-Apple -pie NOT Banana' => ['Apple*', 'pie*', 'Banana*'] '-"Apple pie" -Banana' => ['Apple pie', 'Banana*']

Tags
readonly

$terms

All terms which are required, without operator or with AND or + operator

public array<string|int, string> $terms = []

This is DEFAULT term (for all keyword without operator)

Keyword samples how they are stored here: 'Apple' => ['Apple*'] 'AND Apple' => ['AND*', 'Apple*'] '+Apple' => ['Apple*'] '"Apple"' => ['Apple'] '+"Apple"' => ['Apple'] '+"Apple Banana"' => ['Apple Banana'] 'Apple pie AND Banana' => ['Apple*', 'pie*', 'AND*', 'Banana*'] '"Apple pie" Banana' => ['Apple pie', 'Banana*']

Tags
readonly

Methods

__construct()

public __construct(mixed $query) : mixed
Parameters
$query : mixed

string The search query to parse

addNotTerm()

protected addNotTerm(string $term) : mixed
Parameters
$term : string

addTerm()

protected addTerm(string $term) : mixed
Parameters
$term : string

isNotTerm()

protected isNotTerm(string $term) : bool
Parameters
$term : string
Return values
bool

isPhrase()

protected isPhrase(string $term) : bool
Parameters
$term : string
Return values
bool

parseQuery()

protected parseQuery(string $query) : array<string|int, mixed>
Parameters
$query : string
Return values
array<string|int, mixed>

prepareTerm()

Prepare a term before using

protected prepareTerm(string $term) : string|null
Parameters
$term : string
Return values
string|null

NULL - if the term must not be used at all


        
On this page

Search results