Mysql Equivalent in ElasticSearch updating field based on field
I have an index named "books". In this case, the name and the author's name are two fields with a string type. I need to create a new field so that it doesn't contain the author's name in the title.
Example:
Title: Extended ES Scoring by James Gindal
Author Name: James Gindal
then New_field = Extended ES scoring.
In mysql, I can execute an update query with a simple REPLACE () function. A working solution is required in ES.
+3
source to share
1 answer
use a painless script with _ update_by_query
{
"script": {
"inline": "ctx._source.new_field = 'Advanced Scoring in ES by'",
"lang": "painless"
},
"query": {
"bool": {
"must": [{
"term": {
"title": {
"value": "Advanced Scoring in ES by James Gindal"
}
}
},
{
"term": {
"author_name": {
"value": "James Gindal"
}
}
}
]
}
}
}
0
source to share