-
Notifications
You must be signed in to change notification settings - Fork 189
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
dynamic template support for properties #577
Conversation
this supports dynamic templates
I have no idea why one test is failing, maybe you can give me a hint to fix this.
|
@saimaz You are right, that the index creation is working. But when I try to push data to it I get the following exception: Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [myField]"}],"type":"mapper_parsing_exception","reason":"failed to parse [myField]","caused_by":{"type":"illegal_argument_exception","reason":"unknown property [SOME-DYNAMIC-STUFF]"}},"status":400} In my use case I want to put an array with key, value pairs into myField. |
@saimaz Oh and I just saw that you added an options property to the document definition. When I try this I got the following exception: [Doctrine\Common\Annotations\AnnotationException] |
This is probably because you are using some 0.* version. My example refers to the latest version. Currently 1.0.0-alpha.7 |
If you want to store key value array in some field, you have to define it as object in the dynamic template or document as well. This is how elasticsearch works :). |
Sorry, my bad. your:
is correct. The problem is with the way how you are trying to use elasticsearch IMO. Can you shortly explain what you want to do with your document? |
@saimaz Thank you for your fast response. I think I described my problem not well enough. What I want to do: The definition of the dynamic template is working fine, means the mapping is correctly created in elasticsearch. The problem is that I can not define a property with dynamic content with ongr any more. In some older versions of ongr the "object" type was available WITHOUT using a concret class with concrete properties. That worked fine. So I reintroduced the "object" type for properties WITHOUT using a concret class. Ongr puts the whole array result from the dynamic field into this property, which is fine for me. I hope this explanation makes my problem more clear :) |
Totally clear. I will play a bit with the dynamic templates later to see if there is a quick way to resolve the problem. Maybe the solution could be to create an |
Thank you :) Yeah I thought about this solution as well. Would be more elegant. |
Well, you can extend also a Converter change functionality to support your behaviour and then override it's definition in service.yml. |
Do I understand you right, that my actual proposal is not the way the problem should be solved? I can try another solution. To be honest, I do not think that I can build a quick fix by implementing the |
I'm not saying it's not right. From the first view it looks not very good. I just need some time to think about how to solve it. My suggestions above was how tou could temporary solve the problem in your project. |
Ok, you have a point. I will close this pull request and will look forward to your implementation. Thank you. |
To support dynamic templates you need an abstract property, which can handle any array result.
Scalar types do not work here, so I introduced the property type "object" like in earlier versions.
Now you can do something like: