Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Mapping file not found #191

Open
EOL-Fred opened this issue Sep 4, 2024 · 6 comments
Open

[Chore] Mapping file not found #191

EOL-Fred opened this issue Sep 4, 2024 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@EOL-Fred
Copy link

EOL-Fred commented Sep 4, 2024

Hi,

First, here is my configuration :
Elastically 1.9.2 (tried with 1.9.0 and 1.9.1)
Symfony 7.0.6 with PHP 8.2.21

I have a similar situation to Issue #187, when I try to create the index land-registry I have this error message :

In YamlProvider.php line 37:
Mapping file "/land-registry_mapping.yaml" not found. Please check your configuration.

This is the configuration files I use :

#config/packages/elastically.yaml
elastically:
    connections:
        default:
            client:
                host:                '%env(ELASTICSEARCH_HOST)%'
                # If you want to use the Symfony HttpClient (you MUST create this service)
                #transport:           'JoliCode\Elastically\Transport\HttpClientTransport'

            # Path to the mapping directory (in YAML)
            mapping_directory:       '%kernel.project_dir%/config/elasticsearch'

            # Size of the bulk sent to Elasticsearch (default to 100)
            bulk_size:               100

            # Mapping between an index name and a FQCN
            index_class_mapping:
                land-registry:     App\Model\Location\LandRegisty

            # Configuration for the serializer
            serializer:
                # Fill a static context
                context_mapping:
                    foo:                 bar

            # If you want to add a prefix for your index in elasticsearch (you can still call it by its base name everywhere!)
            # prefix: '%kernel.environment%'
#config/elasticsearch/land-registry_mapping.yaml
settings:
    number_of_replicas: 0
    number_of_shards: 1
    refresh_interval: 60s
mappings:
    dynamic: false
    properties:
        prefix:
            type: text
        section:
            type: text
        planNb:
            type: text
        sheet:
            type: text
        northBound:
            type: double
        southBound:
            type: double
        eastBound:
            type: double
        westBound:
            type: double
        type:
            type: keyword
        layer:
            type: keyword
        text:
            x:
                type: double
            y:
                type: double
            height:
                type: double
            text:
                type: text
            rotation:
                type: double
        polygon:
            type: geo_shape
        extended:
            IDU:
                type: text
            COAR:
                type: text
            INDP:
                type: text
            SUPF:
                type: text
@SalvadorCardona
Copy link

I has exactly the same problem of you.

My config is good :

image

When i use the debugger, i can see in Yaml Provider the configuration Directory is not set

image

@SalvadorCardona
Copy link

And When i try to surcharge YamlProvider with this config, my Service is never runned

image

@damienalexandre
Copy link
Member

Are you using the provided service?

Can you show some code? Because it's very suspicious that the configurationDirectory is empty.

I just tried on a new project, and I cannot reproduce.

With the same config as in the README and you, this works:

<?php

namespace App\Controller;

use JoliCode\Elastically\IndexBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;

class HomeController extends AbstractController
{
    #[Route('/', name: 'app_home')]
    public function index(IndexBuilder $builder): JsonResponse
    {
        $builder->createIndex('my-foobar-index');

        return $this->json([
            'message' => 'Welcome to your new controller!',
            'path' => 'src/Controller/HomeController.php',
        ]);
    }
}

But if you get the IndexBuilder in another way, it may break.

So I need to know how you used it 👍

@damienalexandre damienalexandre added bug Something isn't working invalid This doesn't seem right labels Nov 13, 2024
@SalvadorCardona
Copy link

Are you using the provided service?

Can you show some code? Because it's very suspicious that the configurationDirectory is empty.

I just tried on a new project, and I cannot reproduce.

With the same config as in the README and you, this works:

<?php

namespace App\Controller;

use JoliCode\Elastically\IndexBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;

class HomeController extends AbstractController
{
    #[Route('/', name: 'app_home')]
    public function index(IndexBuilder $builder): JsonResponse
    {
        $builder->createIndex('my-foobar-index');

        return $this->json([
            'message' => 'Welcome to your new controller!',
            'path' => 'src/Controller/HomeController.php',
        ]);
    }
}

But if you get the IndexBuilder in another way, it may break.

So I need to know how you used it 👍

The problem, when this tutorial :
https://jolicode.com/blog/elasticsearch-the-right-way-in-symfony

In this tutorial, i can see get the service by the client service like this :

$indexBuilder = $this->client->getIndexBuilder();
$newIndex = $indexBuilder->createIndex('post');
$indexer = $this->client->getIndexer();

i has resolved this problem when i inject each service by autowiring like this :

image

@damienalexandre
Copy link
Member

Oh ok I see. The library changed a lot since the tutorial, we need to make some changes on it.

Thanks for the feedback I'm leaving this issue open until the tutorial is fixed as well.

@damienalexandre damienalexandre changed the title Mapping file not found [Chore] Mapping file not found Nov 14, 2024
@damienalexandre damienalexandre added help wanted Extra attention is needed and removed bug Something isn't working invalid This doesn't seem right labels Nov 14, 2024
@SalvadorCardona
Copy link

Oh ok I see. The library changed a lot since the tutorial, we need to make some changes on it.

Thanks for the feedback I'm leaving this issue open until the tutorial is fixed as well.

Now, i has new problem why i has abandoned Elastically. I just return this problem.

I use the last version of Api Platform and has library conflict beetween Api Platform and Elasticaly.

But it's an other problem.

Good day for you 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants