Fyi: Since I just tested what @olof suggested here's how you would use regular expressions to extract stuff from existing fields.
Given a document in Elasticsearch that looks like this:
{
"_index": "test",
"_type": "tweet",
"_id": "4",
"_score": 1,
"_source": {
"date": "2014-09-16",
"name": "John Smith",
"tweet": "The Elasticsearch API is really easy to use",
"user_id": 1
}
}
You could extract the first name from the name field like this:
GET test/_search
{
"script_fields": {
"first_name": {
"script": "/\\w+/.exec(_source['name'])[0]",
"lang": "javascript"
}
},
"_source": "*"
}
Install the Javascript plugin before.