Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature Class Reference

Handles the search keyword 'haswbstatement:'. More...

+ Inheritance diagram for Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature:
+ Collaboration diagram for Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature:

Public Member Functions

 __construct (array $foreignRepoNames)
 HasWbStatementFeature constructor. More...
 
 parseValue ( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector)
 
 getFilterQuery (KeywordFeatureNode $node, QueryBuildingContext $context)
 

Protected Member Functions

 getKeywords ()
 
 doApply (SearchContext $context, $key, $value, $quotedValue, $negated)
 

Detailed Description

Handles the search keyword 'haswbstatement:'.

Allows the user to search for pages/items that have wikibase statements associated with them.

If a file page has the statement 'wikidata:P180=wikidata:Q527' (meaning 'depicts sky') associated with it then it can be found by including 'haswbstatement:wikidata:P180=wikidata:Q527' in the search query.

If a file page has the statement 'wikidata:P2014=79802' (meaning 'MoMA artwork id 79802') associated with it then it can be found by including 'haswbstatement:wikidata:P2014=79802' in the search query.

Statements can be combined using logical OR by separating them with a | character in a single haswbstatement query e.g. 'haswbstatement:P999=Q888|P999=Q777'

Statements can be combined using logical AND by using two separate haswbstatement queries e.g. 'haswbstatement:P999=Q888 haswbstatement:P999=Q777'

Note that NOT ALL STATEMENTS ARE INDEXED. Searching for a statement about a property that has not been indexed will give an empty result set.

@uses CirrusSearch

Todo:
Move to WikibaseCirrusSearch extension
See also
https://phabricator.wikimedia.org/T190022

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature::__construct ( array  $foreignRepoNames)

HasWbStatementFeature constructor.

Parameters
array$foreignRepoNamesArray of names of foreign repos from $wgWBRepoSettings

Member Function Documentation

◆ doApply()

Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature::doApply ( SearchContext  $context,
  $key,
  $value,
  $quotedValue,
  $negated 
)
protected
Parameters
SearchContext$context
string$keyThe keyword
string$valueThe value attached to the keyword with quotes stripped
string$quotedValueThe original value in the search string, including quotes if used
bool$negatedIs the search negated? Not used to generate the returned AbstractQuery, that will be negated as necessary. Used for any other building/context necessary.
Returns
array Two element array, first an AbstractQuery or null to apply to the query. Second a boolean indicating if the quotedValue should be kept in the search string.

◆ getFilterQuery()

Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature::getFilterQuery ( KeywordFeatureNode  $node,
QueryBuildingContext  $context 
)
Parameters
KeywordFeatureNode$node
QueryBuildingContext$context
Returns
AbstractQuery|null

◆ getKeywords()

Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature::getKeywords ( )
protected
Returns
string[]

◆ parseValue()

Wikibase\Repo\Search\Elastic\Query\HasWbStatementFeature::parseValue (   $key,
  $value,
  $quotedValue,
  $valueDelimiter,
  $suffix,
WarningCollector  $warningCollector 
)
Parameters
string$key
string$value
string$quotedValue
string$valueDelimiter
string$suffix
WarningCollector$warningCollector
Returns
array|false|null

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