ElasticsearchDSL
ElasticsearchDSL copied to clipboard
Getting Null for array fields
Hi! I am trying to map a hash object from a mongdb collection, using object type , but I am geting null value.
<?
/**
* @ES\Property(type="object")
* @MongoDB\hash
*/
protected $data;
Is my mapping wrong? I am using bundle version 1.2 with elasticsearch 2.4.
Thanks in advance,
Hey @dijadev
This issue should be in ElasticsearchBundle.
There is no hash support until 5.x version in ElasticsearchBundle. If you want to use an object, you need to create a separate class and embed it.
Thank you @saimaz for replying.
Unfortunately i can't use another version since my elasticsearch version is 2.4 .
Edit: Actully I figured out that the problem was not in the field type but in the name. My field name is "pageData" and since I did not specify the name in the mapping, the getter getPageData() resolves the name with Snakcase so it returns Null for page_data field.. The solution is to specify the name explicitly in the annotation in this way:
<?
/**
* @ES\Property(name="pageData")
* @MongoDB\hash
*/
protected $pageData;
I'll take a look later this week if I can backport hashmap support to 1.x bundle version.