ongr-io / ElasticsearchBundle

Symfony bundle for Elasticsearch with steroids
MIT License
313 stars 189 forks source link

Mapping for Embed not working when its extended #803

Open alexander-schranz opened 7 years ago

alexander-schranz commented 7 years ago
- PHP: 7.0
- ElasticSearch: 5
- Ongr: 5.0.2

It use the false folder when an embed is from an extended Document: https://github.com/ongr-io/ElasticsearchBundle/blob/v5.0.2/Mapping/DocumentParser.php#L599. The guessDirName returns for SuluArticleBundle:ExcerptViewObject the Bundle/WebsiteBundle/Document/ instead of Document. A strange namespace is then generate Sulu/Bundle/ArticleBundle/Bundle/WebsiteBundle/Document in https://github.com/ongr-io/ElasticsearchBundle/blob/v5.0.2/Mapping/DocumentParser.php#L572.

Folder Structure:

 - src
   - Client
      - Bundle
        - WebsiteBundle
          - Document
            - ArticleViewDocument extends ArticleBundle:ArticleViewDocument

 - vendor
    - sulu
       - article-bundle
         - Document
           - ArticleViewDocument
           - ExcerptViewObject

ArticleBundle:ArticleViewDocument

    /**
     * @var ExcerptViewObject
     *
     * @Embedded(class="SuluArticleBundle:ExcerptViewObject")
     */
    protected $excerpt;
alexander-schranz commented 6 years ago

@saimaz this issue make more and more problems in our projects can you give me some feedback?

saimaz commented 6 years ago

I'll take a look what is the problem here and let you know.

alexander-schranz commented 6 years ago

@saimaz any news? do you need more information? should I create a test project where the error appears?

saimaz commented 6 years ago

I'm trying to repeat the error. No luck yet. The way you are trying to use the mapping is very rare :). I can imagine what you want to achieve and will try to work on a possible solution.

alexander-schranz commented 6 years ago

@saimaz The problem is that it use the current document dir for embedded object instead of the one of that namespace. If I completely removes that the document parser care about Document Dirs (https://github.com/ongr-io/ElasticsearchBundle/pull/804) it works. Think only the document finder should care about document how they should be loaded.

If you use ongr in a third party bundle you want that the developer who use it can extend document. I know its not a normal project use case where all your documents are in the src/AppBundle/Document.

martiis commented 6 years ago

+1

kleinkoerkamp commented 6 years ago

+1

stein189 commented 6 years ago

+1

eboezelman commented 6 years ago

+1

saimaz commented 5 years ago

Added v6 label to test this if it works well in the upcoming v6 major version.

alexander-schranz commented 5 years ago

@saimaz want to mention it that this bug did only happen with the : syntax the last time I did test it. It did not happened when using FQCN.