ElasticsearchBundle icon indicating copy to clipboard operation
ElasticsearchBundle copied to clipboard

Mapping for Embed not working when its extended

Open alexander-schranz opened this issue 7 years ago • 11 comments

- 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 avatar Jul 25 '17 10:07 alexander-schranz

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

alexander-schranz avatar Jul 27 '17 14:07 alexander-schranz

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

saimaz avatar Jul 28 '17 10:07 saimaz

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

alexander-schranz avatar Jul 31 '17 11:07 alexander-schranz

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.

saimaz avatar Jul 31 '17 12:07 saimaz

@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.

alexander-schranz avatar Jul 31 '17 13:07 alexander-schranz

+1

martiis avatar Aug 28 '17 08:08 martiis

+1

kleinkoerkamp avatar Oct 11 '17 19:10 kleinkoerkamp

+1

stein189 avatar Jan 09 '18 13:01 stein189

+1

eboezelman avatar Jan 09 '18 14:01 eboezelman

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

saimaz avatar Mar 21 '19 20:03 saimaz

@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.

alexander-schranz avatar Mar 22 '19 08:03 alexander-schranz