Skip to content

Instantly share code, notes, and snippets.

@johnl
Last active January 3, 2016 08:49
Show Gist options
  • Save johnl/8438391 to your computer and use it in GitHub Desktop.
Save johnl/8438391 to your computer and use it in GitHub Desktop.
elastic search analyzer examples for email addresses
# curl -XGET 'localhost:9200/test/_analyze?pretty=true&analyzer=standard' -d '[email protected]'
{
"tokens" : [ {
"token" : "john.smith",
"start_offset" : 0,
"end_offset" : 10,
"type" : "<ALPHANUM>",
"position" : 1
}, {
"token" : "example",
"start_offset" : 11,
"end_offset" : 18,
"type" : "<ALPHANUM>",
"position" : 2
}, {
"token" : "one.com",
"start_offset" : 19,
"end_offset" : 26,
"type" : "<ALPHANUM>",
"position" : 3
} ]
}
# curl -XGET 'localhost:9200/test/_analyze?pretty=true&analyzer=simple' -d '[email protected]'
{
"tokens" : [ {
"token" : "john",
"start_offset" : 0,
"end_offset" : 4,
"type" : "word",
"position" : 1
}, {
"token" : "smith",
"start_offset" : 5,
"end_offset" : 10,
"type" : "word",
"position" : 2
}, {
"token" : "example",
"start_offset" : 11,
"end_offset" : 18,
"type" : "word",
"position" : 3
}, {
"token" : "one",
"start_offset" : 19,
"end_offset" : 22,
"type" : "word",
"position" : 4
}, {
"token" : "com",
"start_offset" : 23,
"end_offset" : 26,
"type" : "word",
"position" : 5
} ]
}
# curl -XGET 'localhost:9200/test/_analyze?pretty=true&analyzer=whitespace' -d '[email protected]'
{
"tokens" : [ {
"token" : "[email protected]",
"start_offset" : 0,
"end_offset" : 26,
"type" : "word",
"position" : 1
} ]
}
# curl -XGET 'localhost:9200/test/_analyze?pretty=true&analyzer=standard' -d '[email protected]'
{
"tokens" : [ {
"token" : "john.smith",
"start_offset" : 0,
"end_offset" : 10,
"type" : "<ALPHANUM>",
"position" : 1
}, {
"token" : "example.com",
"start_offset" : 14,
"end_offset" : 25,
"type" : "<ALPHANUM>",
"position" : 3
} ]
}
# curl -XGET 'localhost:9200/test/_analyze?pretty=true&analyzer=simple' -d '[email protected]'
{
"tokens" : [ {
"token" : "john",
"start_offset" : 0,
"end_offset" : 4,
"type" : "word",
"position" : 1
}, {
"token" : "smith",
"start_offset" : 5,
"end_offset" : 10,
"type" : "word",
"position" : 2
}, {
"token" : "an",
"start_offset" : 11,
"end_offset" : 13,
"type" : "word",
"position" : 3
}, {
"token" : "example",
"start_offset" : 14,
"end_offset" : 21,
"type" : "word",
"position" : 4
}, {
"token" : "com",
"start_offset" : 22,
"end_offset" : 25,
"type" : "word",
"position" : 5
} ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment