Based on the investigation in T362005, we decided to enable searching of EntitySchemas by label and aliases via the `wbsearchentities` API in order to allow selecting EntitySchemas by label/ aliases when editing statements. This API is already being used by the relevant EntitySchema expert.
Analogue to the implementation for other entity types that have labels, we chose to use Elastic (via CirrusSearch) for this search. To do this, we need to add new search fields to Elastic as we can't re-use the `labels` and `labels_all` fields from Wikibase (as the MediaWiki side definitions of these require proper entities). Luckily we can still copy and adapt parts of WikibaseCirrusSearch for our needs.
This probably wont affect Special:Search at all as we (are forced to) use different indexes so `haslabel:…` wont work for EntitySchemas (but that is beyond our scope).
**Acceptance criteria:**
[] EntitySchemas can be found by label and aliases via wbsearchentities
[] The wbsearchentities results are formatted consistently with other entity types
[] In statements EntitySchemas can be added by label and aliases (this should just work, the correct API is already being used)
[] Language fallback chains are correctly applied when searching for EntitySchemas
**Rough implementation outline:**
1. Create (by copying and removing Wikibase dependencies from) new field definitions for labels (equivalent to the `labels` and `labels_all` fields for other entity types - `labels_all` is used for supporting language fallback)
1. This is https://gerrit.wikimedia.org/r/c/mediawiki/extensions/EntitySchema/+/1071938/1/src/LabelsField.php and https://gerrit.wikimedia.org/r/c/mediawiki/extensions/EntitySchema/+/1071938/1/src/AllLabelsField.php in the PoC
1, Run the maintenance script?
1. Wire these up in `EntitySchemaContentHandler`: With that done we will have our labels indexed, ready to be queried.
1. This is https://gerrit.wikimedia.org/r/c/mediawiki/extensions/EntitySchema/+/1071938/1/src/MediaWiki/Content/EntitySchemaContentHandler.php in the PoC
1. Create a new `EntitySearchHelper` implementation that can be switched in via configuration, similar to [EntitySearchElastic in the WikibaseCirrusSearchExtension](https://github.com/wikimedia/mediawiki-extensions-WikibaseCirrusSearch/blob/master/src/EntitySearchElastic.php).
1. In the PoC this is https://gerrit.wikimedia.org/r/c/mediawiki/extensions/EntitySchema/+/1071938/1/src/Wikibase/Search/EntitySchemaSearchHelper.php (although while working this is fairly incomplete, entirely lacking search profiles).