-
Notifications
You must be signed in to change notification settings - Fork 62
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
Related Model Collections - Mappable Data and ElasticSearch Datatypes #229
Comments
Small followup, I did confirm I could control the mapping from the root model:
Its not quite as elegant as I'd like but I recognize that might be a scout limitation. Still if there is a way to do it more per-model rather than the root model I'd love to know it. |
Thank you for the elaborate description, really! 👏 I dove into the source and this is the culprit: It does nothing to see what happens in the root, it expects a plain array in return. Apparently you are the first to encounter this or be bothered by it😁 Unless you know of a smart solution I think you will have to do everything as you showed in the root toSearchableArray. |
Thanks @Jeroen-G for confirming I wasn't missing anything! I guess that explains why it doesn't work. For now I've gone ahead and set up my root document to call the I did want to follow up on one thing though: the nested object field mappings are also not being used to create the index in Elastic. For example, in the code I give above with something like a Candidate, CandidateHasSkill, and Skill object, In the How do tell Elastic what the field types for https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html Is there a way to define a nested object's field mappings? |
There is a bit on nested mappings here: https://jeroen-g.github.io/Explorer/mapping.html which might help you! I think this could work: return [
'id' => 'keyword',
'candidate_skills' => [
'name' => 'keyword'
]
]; |
Hello
Thank you for the hardwork on this package it is exactly what I was hoping to find to get an elastic based index up for my app.
I have a document with attached models, that could be a HasOne or HasMany relationship. I want to include all the attached entities as part of the document to be indexed. I was hoping I could just define for each model the
mappableAs
function and as the indexing was taking place, it would jump through each of the relationships, get the mapped data and field types as defined and map those fields accordingly.That doesn't seem to happening. When I set up the
nested
field type, it does include the model I want, but its not mapping the field types. I did customize thetoSearchableArray
method on a child model, and even though I only returned a single field, the request to index is getting all the related model's fields. So, it doesn't seem to be referencingmappableAs
ortoSearchableArray
when navigating through the root entity attach the nested models.Example code of how I have things configured:
Candidate.php
CandidateHasSkill.php
Skill.php
I guess my specific questions / issues are:
prepare
ortoSearchableArray
on my root document array, I might be able to achieve what I'm wanting, but I was hoping to have the concerns split across the model classes.nested
type.The text was updated successfully, but these errors were encountered: