jolicode / elastically

🔍 JoliCode's Elastica wrapper to bootstrap Elasticsearch PHP integrations
248 stars 37 forks source link

Ability to change mapping filename #120

Closed insekticid closed 1 year ago

insekticid commented 1 year ago

if using non standardized mapping file naming

//this will work
 $indexBuilder->migrate($this->elasticallyClient->getIndex($indexName), [], ['filename' => 'content_mapping.yaml']);

//this works
$index = $indexBuilder->createIndex($indexName, ['filename' => 'content_mapping.yaml']);
damienalexandre commented 1 year ago

Thanks a lot - that was a bug indeed.

In the next major version I intend to remove this context (https://github.com/jolicode/elastically/issues/115) because it's a source of confusion and error - mapping providers are going to be more robust that way.

I will release this patch very soon. Thanks!

insekticid commented 1 year ago

@damienalexandre Ok, so think about solution, how to use same mapping file for more indexes. I have indexes with prefix content- + langName (e.g. cs, de, sk...) so I do not want to make copies of content_mapping.yaml file with the same config. Or think about extending from base mapping file and use something like

content_cs_mapping.yaml:

imports:
  - { resource: ' content_mapping.yaml' }

content_de_mapping.yaml:

imports:
  - { resource: ' content_mapping.yaml' }
damienalexandre commented 1 year ago

Yes, thanks for the suggestion :+1:

We will do our best to include this in the YamlMappingProvider, and if not possible, you always have the possibility of building your own mapping provider with the https://github.com/jolicode/elastically/blob/master/src/Mapping/MappingProviderInterface.php.