Great. Thanks for the feedback.
Thank you very much David for your help. It's fine now.
Concerning the changement of the example, I do it because I think that the second example is more simple.
Sorry for disturbance
Best Regards
Rami
2012/7/26 David Pilato david@pilato.fr
I never used scripting but looking at the documentation ( Elasticsearch Platform — Find real-time answers at scale | Elastic ), it's said:
"Also, the doc[...] notation only allows for simple valued fields (can’t return a json object from it) and make sense only on non analyzed or single term based fields."
So you probably should write something like:
{
"query" : {
...
},
"script_fields" : {
"test1" : {
"script" : "_source.popup"
}
}
}
BTW, it's difficult to follow you and to help you.
You start with an example which is about a Menu with inline objects (popup) and then you send a question that has nothing in common with the first question (flat structure with attribute gender).
Hard to follow = hard to provide the best answer.
David.
Le 26 juillet 2012 à 16:50, rami sellami sel.rami@gmail.com a écrit :
No it's no the problem, even though I changed it still the same error :
{
"took" : 14,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"status" : 500,
"reason" : "CompileException[[Error: No field found for [org.elasticsearch.index.field.data.strings.StringDocFieldData@4fc9584f] in mapping with types [rami]]\n[Near : {... doc[Gender].value ....}]\n ^\n[Line: 1, Column: 1]]; nested: ElasticSearchIllegalArgumentException[No field found for [org.elasticsearch.index.field.data.strings.StringDocFieldData@4fc9584f] in mapping with types [rami]]; "
}, {
"status" : 500,
"reason" : "CompileException[[Error: No field found for [org.elasticsearch.index.field.data.strings.StringDocFieldData@182a3bb3] in mapping with types [rami]]\n[Near : {... doc[Gender].value ....}]\n ^\n[Line: 1, Column: 1]]; nested: ElasticSearchIllegalArgumentException[No field found for [org.elasticsearch.index.field.data.strings.StringDocFieldData@182a3bb3] in mapping with types [rami]]; "
} ]
},
"hits" : {
"total" : 2,
"max_score" : 0.30935922,
"hits" :
}
}
Le jeudi 26 juillet 2012 16:33:01 UTC+2, David Pilato a écrit :
Pb is Gender vs gender
David.
Le 26 juillet 2012 à 16:22, rami sellami < sel.rami@gmail.com> a écrit :
Thank you David.
I have a mistake, could you check with me please ?
So this a sample of a document :
{
"lastName": "Sellami",
"firstName": "Rami",
"gender": "Male"
}
And this is the command :
curl -XGET http://localhost:9200/rami/rami/_search?pretty=1 -d '{
"fields" : ["Gender"],
"query" : {
"query_string" :{"query" : "Male"}
},
"script_fields" : {
"test1" : {
"script" : "doc['Gender'].value"
}}
}'
What is wron with that??
Le jeudi 26 juillet 2012 13:10:19 UTC+2, David Pilato a écrit :
Have a look at Elasticsearch Platform — Find real-time answers at scale | Elastic
It should help you to return a field instead of your _source field.
HTH
David.
Le 26 juillet 2012 à 12:10, rami sellami < sel.rami@gmail.com> a écrit :
Dear all,
I want to know whether there is a way to return as output a part of the JSON documents and not the whole JSON documents.
I give you an example (This is the supposed result):
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
In my case I want to return only a part of the JSON document:
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
NB: I am using couchDB to the document database.
Could you please help me?
Best regards,
Rami Sellami
--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
--
Cordialement,
Rami Sellami