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 created database\mappings\app_models_knowledgebase.php
And put there:
<?phpuseSleimanx2\Plastic\Facades\Map;
useSleimanx2\Plastic\Map\Blueprint;
useSleimanx2\Plastic\Mappings\Mapping;
class AppModelsKnowledgeBase extends Mapping
{
/** * Full name of the model that should be mapped * * @var string */protected$model = App\Models\KnowledgeBase\KnowledgeBase::class;
/** * Run the mapping. * * @return void */publicfunctionmap()
{
Map::create($this->getModelType(), function(Blueprint$map){
$map->string('title');
$map->string('content');
$map->string('status');
$map->nested('tags', function (Blueprint$map) {
$map->integer('id');
$map->string('name');
});
}, $this->getModelIndex());
}
}
Also within my model I have:
publicfunctionbuildDocument()
{
return [
'title' => $this->title,
'content' => $this->content,
'tags' => $this->tags,
'status' => $this->status,
];
}
/** * Add tags attribute * * @return \Illuminate\Database\Eloquent\Collection */publicfunctiongetTagsAttribute()
{
return$this->tags()->get();
}
/** * Get all of the tags for the article. */publicfunctiontags()
{
return$this->morphToMany(
Tag::class,
TagRelation::RELATION_NAME,
TagRelation::TABLE_NAME
);
}
So question is how can I populate data,
when I run
artisan plastic:populate --mappings
it says:
Index « test » does not exists.
And if I try to index document before
$knowledgeBase->document()->save();
so then when I run
artisan mapping:rerun
it says:
Elasticsearch\Common\Exceptions\BadRequest400Exception : {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"object mapping [tags] can't be changed from non-nested to nested"}],"type":"illegal_argument_exception","reason":"object mapping [tags] can't be changed from non-nested to nested"},"status":400}
The text was updated successfully, but these errors were encountered:
Hello, thank you for your package it's awesome.
I have created database\mappings\app_models_knowledgebase.php
And put there:
Also within my model I have:
So question is how can I populate data,
when I run
it says:
And if I try to index document before
so then when I run
it says:
The text was updated successfully, but these errors were encountered: