SolrBundle icon indicating copy to clipboard operation
SolrBundle copied to clipboard

Merged all open PR's request into one pull request

Open jkwakman opened this issue 6 years ago • 4 comments

Bundled all changes into one PR. Merging and maintaining all the separate PR's causes a mess.

jkwakman avatar Sep 11 '18 13:09 jkwakman

I will test your pull-request in the end of the week

floriansemm avatar Oct 22 '18 12:10 floriansemm

Dear Florian,

Thank you for you're time reviewing my PR. I have added the following changes (see commits):

  • Added fix for inserting array of objects instead of doctrine annotation data.
  • Added test testReadPropertiesMultipleFields in AnnotationReaderTest.php
  • Added extra tests for exceptions:

testGetFields_NoParentGetter testGetFields_UnkownParentGetterMethod testGetFields_NoFieldAlias testGetFields_NoFieldGetter testGetFields_UnknownFieldGetter

  • Removed newlines and added missing spaces.

Can you please reevaluate my PR? If you require any further information, feel free to contact me.

Kind regards,

Jack Kwakman

jkwakman avatar Oct 26 '18 12:10 jkwakman

I have tested your feature with an Post entity that has a tags property.

    /**
     * @Solr\Fields(getter="getTags", fields={
     *      @Solr\Field(type="integers", getter="getId", fieldAlias="id"),
     *      @Solr\Field(type="strings", getter="getName", fieldAlias="name")
     *      })
     *
     * @ORM\OneToMany(targetEntity="Acme\DemoBundle\Entity\Tag", mappedBy="post", cascade={"persist", "remove"})
     */
    private $tags;

When I persist a post then an error is logged:

solr.DEBUG: Unknown method defined "getId" in class "Acme\DemoBundle\Entity\Post" Post has an getId method, but I would expect that Tag::getId is called in this case.

        $post = new Post();
        $post->setTitle('post with fields');
        $post->setText('text');

        $tag1 = new Tag();
        $tag1->setName('tag #1');

        $tag2 = new Tag();
        $tag2->setName('tag #2');

        $post->setTags([$tag1, $tag2]);
        // save $post comes here....

Did I have misunderstood the documentation?

floriansemm avatar Oct 26 '18 17:10 floriansemm

Dear Florian,

I have reevaluated the changes with the example in the docs. I have e-mailed the example entities so we can be sure we test the same setup. These entities are working without errors on my side and update the Solr database with the following result:

{ "id":"post_15", "id_is":[29,30], "name_ss":["tag #1","tag #2"], "version":1615765069600129024}] } The tag id's are grouped in the id_is property and the names are grouped under the name_ss. This setup also works for @ManyToOne relationships and can be defined with the same annotation syntax.

Can you please (re)reevaluate my PR? If you require any further information, feel free to contact me.

Kind regards,

Jack Kwakman

jkwakman avatar Oct 30 '18 15:10 jkwakman