Smalyshev has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/381068 )
Change subject: [WIP] Index descriptions for Wikibase
......................................................................
[WIP] Index descriptions for Wikibase
Bug: T176903
Change-Id: Ie304527c41c364e0bdb536cb04cb066fff6c6d7b
---
M repo/includes/Search/Elastic/Fields/DescriptionsField.php
M repo/includes/Search/Elastic/Fields/LabelsField.php
2 files changed, 32 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/68/381068/1
diff --git a/repo/includes/Search/Elastic/Fields/DescriptionsField.php
b/repo/includes/Search/Elastic/Fields/DescriptionsField.php
index 59bf1c4..66a4651 100644
--- a/repo/includes/Search/Elastic/Fields/DescriptionsField.php
+++ b/repo/includes/Search/Elastic/Fields/DescriptionsField.php
@@ -1,6 +1,7 @@
<?php
namespace Wikibase\Repo\Search\Elastic\Fields;
+use CirrusSearch;
use SearchEngine;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Term\DescriptionsProvider;
@@ -8,7 +9,7 @@
/**
* Field which contains per-language specific descriptions.
*/
-class DescriptionsField implements WikibaseIndexField {
+class DescriptionsField extends TermIndexField {
/**
* List of available languages
@@ -21,17 +22,37 @@
*/
public function __construct( array $languages ) {
$this->languages = $languages;
+ parent::__construct( "", \SearchIndexField::INDEX_TYPE_NESTED );
}
/**
* @param SearchEngine $engine
- * @param string $name
- * @return null|\SearchIndexField
+ * @return null|array
*/
- public function getMappingField( SearchEngine $engine, $name ) {
- // TODO: no mapping for now, since we're only storing it for
retrieval
- // When we start indexing it, we'll need to figure out how to
add proper analyzers
- return null;
+ public function getMapping( SearchEngine $engine ) {
+ // Since we need a specially tuned field, we can not use
+ // standard search engine types.
+ if ( !( $engine instanceof CirrusSearch ) ) {
+ // For now only Cirrus/Elastic is supported
+ return [];
+ }
+
+ $config = [
+ 'type' => 'object',
+ 'properties' => []
+ ];
+ foreach ( $this->languages as $language ) {
+ $langConfig = $this->getUnindexedField();
+
+ // FIXME: now this config copies labels, but should
have proper analyzer handling
+ $langConfig['fields']['near_match_folded'] =
+ $this->getSubfield( 'near_match_asciifolding' );
+ $langConfig['fields']['near_match'] =
$this->getSubfield( 'near_match' );
+ // TODO: should we also have *_all field? Or add
descriptions to "all"?
+ $config['properties'][$language] = $langConfig;
+ }
+
+ return $config;
}
/**
diff --git a/repo/includes/Search/Elastic/Fields/LabelsField.php
b/repo/includes/Search/Elastic/Fields/LabelsField.php
index d2f84b3..175679b 100644
--- a/repo/includes/Search/Elastic/Fields/LabelsField.php
+++ b/repo/includes/Search/Elastic/Fields/LabelsField.php
@@ -18,6 +18,10 @@
*/
private $languages;
+ /**
+ * LabelsField constructor.
+ * @param string[] $languages
+ */
public function __construct( $languages ) {
$this->languages = $languages;
parent::__construct( "", \SearchIndexField::INDEX_TYPE_NESTED );
--
To view, visit https://gerrit.wikimedia.org/r/381068
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie304527c41c364e0bdb536cb04cb066fff6c6d7b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits