You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem with the _routing field in ElasticSearch. I'll explain step by step my code and I hope there is someone who can help me out.
Mapping
At first I create my Mapping in ElasticSearch. (My index and type)
My index is 'books' and my types are 'book' and 'chapter'.
I make this index with the following code:
I have an action in the BookController called "actionCreate()" for creating a book, "actionUpdate()" for updating a book and "actionDelete()" for deleting a book.
The parameter $id is the Primary Key ( _id ) of the book.
In my ChapterController do I have an action called "actionCreate()" to make a chapter.
The model of Chapter has an "id_parent_helper". Which can be set in the create form, when I make a chapter. This field is the id_parent of the chapter.
In my ChapterController do I have an action called "actionUpdate()" to update a chapter.
The parameter $id is the Primary Key of the chapter you want to update.
As you can see I have to set the "routing". When I dont set the "routing" then i'll get the error:
"routing_missing_exception".
"Routing" is now an _id of a book, which one is the parent of this chapter.
Later I have to set this routing automaticly.
Do I create my models on the right way? Do I have my code right? Do I have to set the routing value? And what is exactly the meaning of this Routing field?
I'm creating a chapter with Yii::$app->elasticsearch->createCommand()->insert.
Is there an other way to create a chapter? (With a parent-child relationship)
I know there is in Yii2 with MySQL an easy when for creating something.
This is like:
@cebe: I just want to know, if I'm doing this on the right way, because I always get the error "routing_missing_exception". So this is not completely the same topic as the other post.
Hello guys,
I have a problem with the _routing field in ElasticSearch. I'll explain step by step my code and I hope there is someone who can help me out.
Mapping
At first I create my Mapping in ElasticSearch. (My index and type)
My index is 'books' and my types are 'book' and 'chapter'.
I make this index with the following code:
As you can see, there is a parent-child relationship between a book and chapter. Type 'chapter' has a _parent, which is type 'book'.
My Yii Models
I've created a Yii2 Models of ElasticSearch.
This is how my "Book" model looks:
My "Chapter" model look like this:
Creating, updating and deleting a book
I have an action in the BookController called "actionCreate()" for creating a book, "actionUpdate()" for updating a book and "actionDelete()" for deleting a book.
The parameter
$id
is the Primary Key ( _id ) of the book.The code looks as the following:
Creating a chapter
In my ChapterController do I have an action called "actionCreate()" to make a chapter.
The model of Chapter has an "id_parent_helper". Which can be set in the create form, when I make a chapter. This field is the id_parent of the chapter.
The code look as following:
Updating a chapter
In my ChapterController do I have an action called "actionUpdate()" to update a chapter.
The parameter
$id
is the Primary Key of the chapter you want to update.As you can see I have to set the "routing". When I dont set the "routing" then i'll get the error:
"routing_missing_exception".
"Routing" is now an _id of a book, which one is the parent of this chapter.
Later I have to set this routing automaticly.
The code look as following:
The end
Do I create my models on the right way? Do I have my code right? Do I have to set the routing value? And what is exactly the meaning of this Routing field?
I'm creating a chapter with
Yii::$app->elasticsearch->createCommand()->insert
.Is there an other way to create a chapter? (With a parent-child relationship)
I know there is in Yii2 with MySQL an easy when for creating something.
This is like:
Is this also possible for parent-child relationships in ElasticSearch?
I'm very confused and I hope there is someone who can help me out and can bring my brain on the right way!
Kind regards,
Arjan
The text was updated successfully, but these errors were encountered: