diff --git a/Classes/Command/IndexCommand.php b/Classes/Command/IndexCommand.php index 768e4cb..1a16f3a 100644 --- a/Classes/Command/IndexCommand.php +++ b/Classes/Command/IndexCommand.php @@ -73,6 +73,8 @@ protected function getRequest(): ServerRequestInterface return $GLOBALS['TYPO3_REQUEST']; } + + // ddev typo3 liszt-bibliography:index -t 100 // index only 100 docs for testing and dev protected function configure(): void { $this->setDescription('Create elasticsearch index from zotero bibliography')-> @@ -141,17 +143,33 @@ protected function fullSync(InputInterface $input): void $this->bibliographyItems = $collection->pluck('data'); $cursor = 0; // set Cursor to 0, not to bulk size $index = $this->extConf['elasticIndexName']; + + // create a field "fulltext" and copy content of "tx_lisztcommon_searchable" to fulltext + // ToDo: stemming german in Fulltext? + // ToDo: "mappings": {"dynamic": false, // Prevents automatic mapping of all fields to then make individual fields searchable with "properties": {"first_name": { "type": "text"... + $mappingParams = [ + 'index' => $index, + 'body' => [ + 'mappings' => [ + 'properties' => [ + 'fulltext' => [ 'type' => 'text' ], + 'tx_lisztcommon_searchable' => ['type' => 'text', 'copy_to' => 'fulltext'], + ] + ] + ] + ]; + try { // in older Elasticsearch versions (until 7) exists returns a bool if ($this->client->indices()->exists(['index' => $index])) { $this->client->indices()->delete(['index' => $index]); - $this->client->indices()->create(['index' => $index]); + $this->client->indices()->create($mappingParams); } } catch (\Exception $e) { // other versions return a Message object if ($e->getCode() === 404) { $this->io->note("Index: " . $index . " does not exist. Trying to create new index."); - $this->client->indices()->create(['index' => $index]); + $this->client->indices()->create($mappingParams); } else { $this->io->error("Exception: " . $e->getMessage()); $this->logger->error('Bibliography sync unsuccessful. Error creating elasticsearch index.'); @@ -348,6 +366,7 @@ protected function commitBibliography(): void $index = $this->extConf['elasticIndexName']; $params = [ 'body' => [] ]; + $bulkCount = 0; foreach ($this->dataSets as $document) { $params['body'][] = [ 'index' => @@ -366,7 +385,7 @@ protected function commitBibliography(): void $this->client->bulk($params); } - protected function commitLocales(): void +/* protected function commitLocales(): void { $localeIndex = $this->extConf['elasticLocaleIndexName']; $this->io->text('Committing the ' . $localeIndex . ' index'); @@ -390,5 +409,5 @@ protected function commitLocales(): void $this->client->bulk($params); $this->io->text('done'); - } + }*/ }