notes
demo
PUT script_text_v1
{
"mappings": {
"properties": {
"title": {
"type": "text"
},
"first_name": {
"type": "text",
"store": true
},
"last_name": {
"type": "text",
"store": true
}
}
}
}
PUT script_text_v1/_doc/1?refresh
{
"title": "Mr",
"first_name": "Barry",
"last_name": "White"
}
GET script_text_v1/_search
{
"script_fields": {
"source": {
"script": {
"lang": "painless",
"source": "params._source.title + ' ' + params._source.first_name + ' ' + params._source.last_name"
}
},
"stored_fields": {
"script": {
"lang": "painless",
"source": "params._fields['first_name'].value + ' ' + params._fields['last_name'].value"
}
}
}
}
GET kibana_sample_data_logs/_search
{
"script_fields": {
"double_bytes": {
"script": {
"lang": "expression",
"source": "doc['bytes'] * multiplier",
"params": {
"multiplier":2
}
}
}
}
}
PUT script_text/_doc/1?refresh
{
"text": "quick brown fox",
"popularity": 1
}
PUT script_text/_doc/2?refresh
{
"text": "quick fox",
"popularity": 5
}
GET script_text/_search
{
"query": {
"function_score": {
"query": {
"match": {
"text": "quick brown fox"
}
},
"script_score": {
"script": {
"lang": "expression",
"source": "_score * doc['popularity']"
}
}
}
}
}
GET script_text/_search
{
"script_fields": {
"popularity": {
"script": {
"lang": "expression",
"source": "doc['popularity']*markup",
"params": {
"markup":0.2
}
}
}
}
}
PUT script_text_v1
{
"mappings": {
"properties": {
"title": {
"type": "text"
},
"first_name": {
"type": "text",
"store": true
},
"last_name": {
"type": "text",
"store": true
}
}
}
}
点击查看详情
DIY plugin in java
write plugin by java