Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with routing #975

Closed
demianchuk opened this issue Jul 27, 2021 · 1 comment
Closed

Problem with routing #975

demianchuk opened this issue Jul 27, 2021 · 1 comment

Comments

@demianchuk
Copy link
Contributor

demianchuk commented Jul 27, 2021

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?

@demianchuk
Copy link
Contributor Author

Seems I found the reason, please check pull request
#976

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant