/** @var array Feature values */
protected $features = [];
+ /** @const string profile type for completionSearch */
+ const COMPLETION_PROFILE_TYPE = 'completionSearchProfile';
+
+ /** @const string profile type for query independent ranking features */
+ const FT_QUERY_INDEP_PROFILE_TYPE = 'fulltextQueryIndepProfile';
+
/**
* Perform a full text search query and return a result set.
* If full text searches are not supported or disabled, return null.
* @return array
*/
public static function namespacesAsText( $namespaces ) {
- return MediaWikiServices::getInstance()->getSearchEngineConfig()->namespacesAsText();
+ return MediaWikiServices::getInstance()->getSearchEngineConfig()->namespacesAsText( $namespaces );
}
/**
return MediaWikiServices::getInstance()->getSearchEngineConfig()->getSearchTypes();
}
+ /**
+ * Get a list of supported profiles.
+ * Some search engine implementations may expose specific profiles to fine-tune
+ * its behaviors.
+ * The profile can be passed as a feature data with setFeatureData( $profileType, $profileName )
+ * The array returned by this function contains the following keys:
+ * - name: the profile name to use with setFeatureData
+ * - desc-message: the i18n description
+ * - default: set to true if this profile is the default
+ *
+ * @since 1.28
+ * @param $profileType the type of profiles
+ * @return array|null the list of profiles or null if none available
+ */
+ public function getProfiles( $profileType ) {
+ return null;
+ }
+
+ /**
+ * Create a search field definition.
+ * Specific search engines should override this method to create search fields.
+ * @param string $name
+ * @param int $type One of the types in SearchIndexField::INDEX_TYPE_*
+ * @return SearchIndexField
+ * @since 1.28
+ */
+ public function makeSearchFieldMapping( $name, $type ) {
+ return new NullIndexField();
+ }
+
+ /**
+ * Get fields for search index
+ * @since 1.28
+ * @return SearchIndexField[] Index field definitions for all content handlers
+ */
+ public function getSearchIndexFields() {
+ $models = ContentHandler::getContentModels();
+ $fields = [];
+ foreach ( $models as $model ) {
+ $handler = ContentHandler::getForModelID( $model );
+ $handlerFields = $handler->getFieldsForSearchIndex( $this );
+ foreach ( $handlerFields as $fieldName => $fieldData ) {
+ if ( empty( $fields[$fieldName] ) ) {
+ $fields[$fieldName] = $fieldData;
+ } else {
+ // TODO: do we allow some clashes with the same type or reject all of them?
+ $mergeDef = $fields[$fieldName]->merge( $fieldData );
+ if ( !$mergeDef ) {
+ throw new InvalidArgumentException( "Duplicate field $fieldName for model $model" );
+ }
+ $fields[$fieldName] = $mergeDef;
+ }
+ }
+ }
+ // Hook to allow extensions to produce search mapping fields
+ Hooks::run( 'SearchIndexFields', [ &$fields, $this ] );
+ return $fields;
+ }
}
/**