Malcom HAMELIN
Malcom HAMELIN

Reputation: 315

Error in bulk request : index : ... caused failed to parse

I'm having trouble with the FOSElastica bundle config. I'm trying to use the Symfony serializer to populate Elastic search with FOSElastica, and it works well for simple objects which don't need to have groups of attributes, but when I try to serialize only a group of attributes, all I get is the following error :

In Bulk.php line 411:

  Error in one or more bulk request actions:        

  index: /journal/journal/2 caused failed to parse  
  index: /journal/journal/3 caused failed to parse  
  index: /journal/journal/4 caused failed to parse

My config file :

fos_elastica:
    serializer: ~
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        journal:
            types:
                journal:
                    serializer:
                        groups: [elastica]
                    persistence:
                        driver: orm
                        model: TAMAS\AstroBundle\Entity\Journal

My "Journal" entity :

use Symfony\Component\Serializer\Annotation\Groups;

/**
 * Journal
 *
 * @ORM\Table(name="journal")
 * @ORM\Entity(repositoryClass="TAMAS\AstroBundle\Repository\JournalRepository")
 * @UniqueEntity(fields="journalTitle", message="This title is already recorded in the database.")

 */
class Journal {

    /**
     * @Groups({"elastica"})
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="journal_title", type="string", length=500)
     * @Assert\NotBlank()
     */
    private $journalTitle;

    /**
     * @Groups({"elastica"})
     * Get id
     *
     * @return int
     */
    public function getId() {
        return $this->id;
    }

    /**
     * @Groups({"elastica"})
     * Set id
     *
     * @param int $id
     *
     * @return Journal
     */
    public function setId($id) {
        $this->id = $id;
        return $this;
    }

    /**
     * Set journalTitle
     *
     * @param string $journalTitle
     *
     * @return Journal
     */
    public function setJournalTitle($journalTitle) {
        $this->journalTitle = $journalTitle;

        return $this;
    }

    /**
     * Get journalTitle
     *
     * @return string
     */
    public function getJournalTitle() {
        return $this->journalTitle;
    }
}

If I don't put in the config file :

                    serializer:
                        groups: [elastica]

For an entity like this it's ok, the mapping is done and elasticsearch is successfully populating the index. But for entities with circular references for example, I need the serializer and the groups. Would you have an idea about what the problem could be ?

For reference, I'm coding/editing files with Eclipse/Sublime Text and doing my tests through commands and curl requests.

EDIT : I've installed JMS/serializer-bundle, and it works fine. I think there's a real problem between FOSElastica bundle and the Symfony serializer. It feels like a workaround, so if anyone has insights about the problem between the two, it would still be interesting

Upvotes: 1

Views: 1084

Answers (0)

Related Questions