Elastica\Document::toArray PHP Method

toArray() public method

Returns the document as an array.
public toArray ( ) : array
return array
    public function toArray()
    {
        $doc = $this->getParams();
        $doc['_source'] = $this->getData();
        return $doc;
    }

Usage Example

Example #1
0
 /**
  * @group unit
  */
 public function testToArray()
 {
     $id = 17;
     $data = array('hello' => 'world');
     $type = 'testtype';
     $index = 'textindex';
     $doc = new Document($id, $data, $type, $index);
     $result = array('_index' => $index, '_type' => $type, '_id' => $id, '_source' => $data);
     $this->assertEquals($result, $doc->toArray());
 }
All Usage Examples Of Elastica\Document::toArray