Skip to content

Instantly share code, notes, and snippets.

@smbanaie
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smbanaie/309e437157e113cfa56c to your computer and use it in GitHub Desktop.
Save smbanaie/309e437157e113cfa56c to your computer and use it in GitHub Desktop.
PUT republishan/forum/459890
{
"name_sender": "asd asd",
"description": "یبریبر",
"tags": [
"ربیربیر"
],
"date": "1393-02-30",
"follow": [],
"photo_sender": "profile.jpg",
"id_forum": "184e9952c45f404e820563936b059616",
"id_sender": "cc509bc9-f9a6-475d-8e14-e43ee1ceaa6a",
"like": [],
"title": "یبربی",
"visit": 0,
"score": 0,
"reply": [
{
"id_reply": "b05eb255-c59d-4920-abb9-eac31d17d351",
"id_sender": "cc509bc9-f9a6-475d-8e14-e43ee1ceaa6a",
"text_reply": "sfdsdfsdfs sdf sfdf sdf sdf",
"name_sender": "asd asd",
"photo": "profile.jpg"
},
{
"id_reply": "4adc61cf-fdff-4f1f-8866-0c96b357f026",
"id_sender": "cc509bc9-f9a6-475d-8e14-e43ee1ceaa6a",
"text_reply": "sssssssssssssssss",
"name_sender": "asd asd",
"photo": "profile.jpg"
}
]
}
GET republishan/forum/459890
POST republishan/forum/459890/_update
{
"script" : "for (int i = 0; i < ctx._source.reply.size(); i++){if(ctx._source.reply[i].id_reply == id){ctx._source.reply.remove(i) ;i--;}}",
"params" : {
"id" : "4adc61cf-fdff-4f1f-8866-0c96b357f026"
}
}
POST republishan/forum/459890/_update
{
"script" : "for (int i = 0; i < ctx._source.reply.size(); i++){if(ctx._source.reply[i].id_reply == id){ctx._source.reply[i].text_reply = new_text;}}",
"params" : {
"id" : "4adc61cf-fdff-4f1f-8866-0c96b357f026",
"new_text" : "New Text ...."
}
}
*****************************************************************************
Some Other Useful Samples
*****************************************************************************
curl -XPOST 'http://localhost:9200/mystats1/stats1/76.19.199.20/_update' -d '{
"script" : "if(ctx._source.5sects > current5sec){
ctx._source.5seccnt += count }
else
{ ctx._source.5sects=current5sec; ctx._source.5seccnt=1} ;
if(ctx._source.1mints > current1min){ ctx._source.1mincnt += count }
else
{ ctx._source.1mints=current1min;ctx._source.1mincnt = 1; } ;
if(ctx._source.10mints > current10min){ ctx._source.10mincnt += count }
else { ctx._source.10mints=current10min; ctx._source.10mincnt = 1} ;
if(ctx._source.1hrts > current1hr){ ctx._source.1hrcnt += count }
else { ctx._source.1hrts=current1day; ctx._source.1hrcnt = 1} ;
if(ctx._source.1dayts > current1day){ ctx._source.1daycnt += count }
else
{ ctx._source.1dayts=current1day; ctx._source.1daycnt = 1} ;",
"params" : {
"count" : 1,
"current5sec" : "2012-03-28T06:59:55",
"current1min" : "2012-03-28T06:59:00",
"current10min" : "2012-03-28T06:50:00",
"current1hr" : "2012-03-28T06:00:00",
"current1day" : "2012-03-27T07:00:00"
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment