Kirtash
(Sergi)
September 15, 2017, 10:03am
1
Good morning!
I read the documentation about these types of fields but I don't know if is possible what I want do.
Now when I do the search I get the values like these:
{
"id": "41526940A",
"sex": "H",
"prov": "GI",
"provincia": "GIRONA",
"op": 10
}
And I created one script field with this expresion doc['op'].value*2. My intention is that when I do the search I want this format of results:
{
"id": "41526940A",
"sex": "H",
"prov": "GI",
"provincia": "GIRONA",
"op": 10,
"scfield": 20
}
Will can I do my purpose with script fields?
Thanks for all!
Kirtash
(Sergi)
September 15, 2017, 1:10pm
3
Hi!
First of all thanks for the answer.
I did a new index to prove:
"hits": [
{
"_index": "prova",
"_type": "type",
"_id": "AV6FAf4gTEbznHb_Ak4g",
"_score": 1,
"_source": {
"id": "1",
"opinion": "25"
}
}
And my script field is:
scProva expression doc['opinion'].value*2 Number
Now I see that this field exists in the "discover" of kibana. But how can I do that with this search:
GET /prova/_search
Get the structure that appears in the "discover"?
{
"_index": "prova",
"_type": "type",
"_id": "AV6FAf4gTEbznHb_Ak4g",
"_score": 1,
"_source": {
"id": "1",
"opinion": "25"
},
"fields": {
"scProva": [
50
]
}
}
Thanks!
warkolm
(Mark Walkom)
September 16, 2017, 6:42am
4
Please use code formatting on everything, as it can hide syntax that is important.
Is that the actual script expression you are using?
Kirtash
(Sergi)
September 17, 2017, 6:41pm
5
My script is of type expression with this code:
doc['opinion'].value*2
I think that the script is correct because in Kibana I can see this value:
"_index": "prova",
"_type": "type",
"_id": "AV6FAf4gTEbznHb_Ak4g",
"_score": 1,
"_source": {
"id": "1",
"opinion": "25"
},
"fields": {
"scProva": [
50
]
}
}
But I want know how can I can get this JSON structure, because when I do the search I only can obtain the fields inside _source.
Thanks for all the help!
system
(system)
Closed
October 15, 2017, 6:42pm
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.