Hello,
I am currently shipping my data to Elasticsearch using Logstash.
The inner-hit query I am trying to perform is returning an error saying
"failed to create query: [nested] nested object under path [transactions] is not of nested type"
Thus, I've been trying to define the 'transactions' field as a nested field using Logstash filters and output APIs, but I'm keep running into sorts of errors.
You can not convert something else to nested because nested is a datatype in Elasticsearch that represents an array of one or more objects. In Logstash this would be an array of one or more hashes – fields with subfields. I guess your transactions was not an array, but only one element with subfields when it appeared for the first time. So the dynamic mapping mapped it as object (data type for only one object) instead of nested.
Your problem with installing the template might have to do with the template not being compatible with your ES version. That tutorial is from 2017 and uses document types that have been deprecated for a while.
Each block contains 100+ transactions objects under transactions field, and I want the query to only return single transaction that matches the address query instead of the whole document which is a block itself that contains 100+ transactions.
Is there any way to do this without using inner hit?
so yeah I think it is dynamically mapped as an object with multiple fields as you said.
I don't know why because transactions field contains multiple elements.
I don't know how I would define transactions field as nested, or perform the query as the way I want to.
I just realized that the dynamic mapping generally doesn't assign the nested type. It only creates the data type object. Object fields with multiple entries might look the same, but have a different internal representation than nested: https://www.elastic.co/de/blog/managing-relations-inside-elasticsearch
You should probably try to PUT the template in Elasticsearch and check what errors the API throws and then correct the template accordingly.
[2020-07-23T17:35:30,557][INFO ][logstash.outputs.elasticsearch][main] Using mapping template from {:path=>"/usr/local/etc/logstash/ether-mappings.json"}
but my actual index mapping is still not mapped as nested type......
Logstash is giving me a warning saying
[2020-07-23T17:35:30,430][WARN ][logstash.outputs.elasticsearch][main] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>7}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.