Hi,
The API I'm using holds nested json data (i.e, base-derived nodes relation)
When index it in ES, it's flat-json index
What I'm trying to do simply is to aggregate base object with derived object into single chart
E.g.
Base object - x
derived object - y (nested in object x) Display in bar chart all records for objects as single column. Not multiple column
I want to use Lucene's syntax in my dashboard
Could you please post a very simple example data set here (just a couple of docs) in the form that can be pasted into the Kibana dev console so we could load it and try to create the chart you're looking for?
Maybe this post will help you. In this example, the user has data that might be in 3 different fields but they want one field they can search on. So if you create a scripted field that gets either the Project.name: base object or Project.name: dereved object into one string field you can aggregate on that.
Hi @LeeDr
I'm trying to create query to aggregate data (bucket nested aggregation) to put in the scripted field but without success.
The syntax in painless
If I understand you correctly, you can't do that. Scripted fields only access data in individual documents, not aggregations across multiple documents.
I want to create this script to aggregate data for the base object and it's derived (by key). With that, I want create my scripted field.
What do you mean by individual documents ?
Hi Avivc,
I'm sorry but I don't think I can help without some kind of example data we can talk about. Can you post some code we could paste into the dev console to create a few documents that would represent your data to use as an example?
In the Fields aggregation or field formatter? link I posted above I included commands to put a couple of documents using the dev console, and then I used those documents to answer a question. Can you create a couple of sample documents like that and post it here and then what you're trying to aggregate out of that? I can't tell what you're data looks like from your searches.
I'm trying too - but regarding to your link, which is great and very helpful, I need to use PUT for specific field in my documents and not new fields
This field is under a specific type. So when I'm trying to do:
PUT myIndex/myType/1
{
"Project._refObjectName" : "baseObejct/ derivedObject"
}
I'm not getting what I wish for.
Maybe I should add another key:value pair/s to my query?
Hi @LeeDr
I want to simplify it - just taking couple of values for existing key and create scripted field that'll aggregate it to single Object so I can store it in single bar chart. Not related to nested objects
I've tried to follow the steps from your example but no success.
I'm sorry but I still don't understand the data in your docs. I suggested you provide sample data but your single PUT myIndex/myType/1 isn't enough for me to understand your problem.
Can you please provide a couple of sample docs and then explain which field you're trying to aggregate?
I think you're saying that the _refObjName field can have some set of values and you want to create a scripted field that combines some of those. So maybe you can create a scripted field like this;
(I just copied this from another post and changed the field name)
NOTE: I broke it into multiple lines to make it easier to read, but it might have to all be on one line for the scripted field.
When creating a new scripted field, I would always start with a very simple case and make sure it works in Discover first. And then go back and add more to it. So maybe something like this to start with;
if (doc["_refObjName"].value == 'Alt-st-aviv avivScrum') {
return "matches";
} else {
return "no match";
}
Tnx @LeeDr
When I'm creating a very slim scripted field with 1 item (for testing in Discover), I'm getting the next error: "type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [Project._refObjectName] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
I can see that this field is analyze field (text) in Kibana's management
I found this tutorial, but here too, when trying to modify the field like this:
I'm getting the next error: "type": "illegal_argument_exception", "reason": "Mapper for [Project._refObjectName] conflicts with existing mapping in other types:\n[mapper [Project._refObjectName] is used by multiple types. Set update_all_types to true to update [fielddata] across all types.]"
Should I add update_all_types == true ? If so, where? or I'm not in the right direction for solution ?
Are you setting the my_index mapping after docs have been indexed already? If so, you might have to delete the docs, set the mapping, and then load the docs again.
In the console, you can just do DELETE my_index. This is assuming this is test data that you can reload.
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.