Smalyshev has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/334715 )
Change subject: Add contentmodel: query feature ...................................................................... Add contentmodel: query feature Bug: T156371 Change-Id: I54bb866b9d6f39042854c4a56574a4be423d368b --- A includes/Query/ContentModelFeature.php 1 file changed, 39 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/15/334715/1 diff --git a/includes/Query/ContentModelFeature.php b/includes/Query/ContentModelFeature.php new file mode 100644 index 0000000..3f3fb9f --- /dev/null +++ b/includes/Query/ContentModelFeature.php @@ -0,0 +1,39 @@ +<?php + +namespace CirrusSearch\Query; + +use CirrusSearch\Search\SearchContext; +use \Elastica\Query; + +/** + * Content model feature: + * contentmodel:wikitext + * Selects only articles having this content model. + */ +class ContentModelFeature extends SimpleKeywordFeature { + /** + * @return string[] + */ + protected function getKeywords() { + return ['contentmodel']; + } + + /** + * @param SearchContext $context + * @param string $key The keyword + * @param string $value The value attached to the keyword with quotes stripped + * @param string $quotedValue The original value in the search string, including quotes + * if used + * @param bool $negated Is the search negated? Not used to generate the returned + * AbstractQuery, that will be negated as necessary. Used for any other building/context + * necessary. + * @return 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. + */ + protected function doApply( SearchContext $context, $key, $value, $quotedValue, $negated ) { + $query = new Query\Match( 'content_model', [ 'query' => $value ] ); + + return [ $query, false ]; + } +} -- To view, visit https://gerrit.wikimedia.org/r/334715 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I54bb866b9d6f39042854c4a56574a4be423d368b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Smalyshev <smalys...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits