CirrusSearch
Elasticsearch-powered search for MediaWiki
Loading...
Searching...
No Matches
CirrusSearch\Parser\AST\ParsedBooleanNode Class Reference

A boolean expression. More...

+ Inheritance diagram for CirrusSearch\Parser\AST\ParsedBooleanNode:
+ Collaboration diagram for CirrusSearch\Parser\AST\ParsedBooleanNode:

Public Member Functions

 __construct ( $startOffset, $endOffset, array $children)
 
 toArray ()
 
 getClauses ()
 
 accept (Visitor $visitor)
 
- Public Member Functions inherited from CirrusSearch\Parser\AST\ParsedNode
 __construct ( $startOffset, $endOffset)
 
 getStartOffset ()
 
 getEndOffset ()
 

Additional Inherited Members

- Protected Member Functions inherited from CirrusSearch\Parser\AST\ParsedNode
 baseParams ()
 

Detailed Description

A boolean expression.

This "boolean expression" is suited for matching document in search. It's not really describing a binary tree as one would use to a compute a boolean algebra. It is a flat list of clauses where the clauses are not connected to each others but rather describe how individual clause must occur in a given document:

  • MUST
  • MUST_NOT
  • SHOULD

There is a direct relationship between boolean algebra and this representation:

  • A AND B: [ MUST:A, MUST:B ]
  • A OR B: [ SHOULD:A, SHOULD:B ]
  • A AND NOT B: [ MUST:A, MUST_NOT: B ]

But it supports describing something that is impossible to describe in a boolean algebra:

  • [ MUST:A, SHOULD:B ]: here the boolean algebra is not suited since SHOULD:B is pointless but for search it can be considered as a "scoring hint", i.e. give me all docs matching A but it's "better" to have docs matching B as well. When filtering the search backend can silently ignore the SHOULD:B but when scoring it will be taken into account.

In the end this representation makes it possible to support a syntax like: word1 +word2 -word3: [ SHOULD:word1, MUST:word2, MUST_NOT:word3 ] which would not be possible with a binary expression tree

Constructor & Destructor Documentation

◆ __construct()

CirrusSearch\Parser\AST\ParsedBooleanNode::__construct ( $startOffset,
$endOffset,
array $children )
Parameters
int$startOffset
int$endOffset
BooleanClause[]$children

Member Function Documentation

◆ accept()

CirrusSearch\Parser\AST\ParsedBooleanNode::accept ( Visitor $visitor)
Parameters
Visitor$visitor

Implements CirrusSearch\Parser\AST\Visitor\Visitable.

◆ getClauses()

CirrusSearch\Parser\AST\ParsedBooleanNode::getClauses ( )
Returns
BooleanClause[]

◆ toArray()

CirrusSearch\Parser\AST\ParsedBooleanNode::toArray ( )
Returns
array

Reimplemented from CirrusSearch\Parser\AST\ParsedNode.


The documentation for this class was generated from the following file: