Skip to content

Problem with routing #975

@demianchuk

Description

@demianchuk

Hi,
I made next mappings

class Hotels
{
/**
* @var int
* @es\Id()
*/
public $id;

/**
 * @var int
 * @ES\Routing()
 */
public $routing;

/**
 * @var Hotel
 * @ES\Embedded(class="App\Document\Hotel")
 */
public $hotel;

/**
 * @var Booking
 * @ES\Embedded(class="App\Document\Booking")
 */
public $booking;

/**
 * @var string
 * @ES\Property(
 *  type="join",
 *  name="hotel_bookings_join_field",
 *  settings={
 *     "relations"={"hotel_parent": "booking_child"}
 *  }
 * )
 */
public $hotelBookingsJoinField;

public function __construct()
{
    $this->hotel = [];
    $this->booking = [];
}

}

Than I have hotel object as a parent

/**

  • @es\ObjectType()
    */
    class Hotel
    {
    ......
    }`

and booking as a child

/**

  • @es\ObjectType()
    /
    class Booking
    {
    /
    *
    • @var float
    • @es\Property(name="price", type="float")
      */
      public $price;
      }

while indexing parent document - all is working

but I am trying to index child document
e.g

$booking = new Booking();
$booking->price = 100;

$document = new Hotels();
$document->id = '2';
$document->routing = 1;
$document->booking = $booking;
$document->hotelBookingsJoinField = ['name' => 'booking_child', 'parent' => 1];
$indexManager = $this->container->get(Hotels::class);
$indexManager->persist($document);
$indexManager->commit();

#message: "{"took":0,"errors":true,"items":[{"index":{"_index":"hotels","_type":"_doc","_id":"1-2","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"illegal_argument_exception","reason":"[routing] is missing for join field [hotel_bookings_join_field]"}}}}]}"

Seems @es\Routing() is not processed properly but I cant get where is it done at all
Can anybody help with that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions