Search email addresses in ElasticSearch by regexp -
how can search in elastic regexp find email addresses?
i try that:
{ "query": { "regexp": { "data": { "value": "[\\w\\'\\.\\_\\+\\-]+@[\\w]+[\\w\\-\\.]*\\.[\\w]+", "flags": "all" } } } }
but nothing.
there https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-regexp-query.html written simbol @ means symbol , therefore should escaped.
therefore try that:
{ "query": { "regexp": { "data": { "value": "\\@", "flags": "all" } } } }
and that:
{ "query": { "regexp": { "data": { "value": "\\@", "flags": "all" } } } }
but nothing again.
any thoughts?
update use elastic search of 5.2 version on ubuntu ubuntu 16.04.2 lts.
data samples:
curl -xpost 'localhost:9200/my_index/index_type/_bulk?pretty' -h 'content-type: application/json' -d' {"index":{"_id":"1"}} {"data":"some text text text text admin@company.comsome text text text "} {"index":{"_id":"2"}} {"data":"some text text hr@company.comsome text text "} {"index":{"_id":"3"}} {"data":"some text text webmaster@company.comsome text text "}
and searching query:
curl -xget 'localhost:9200/my_index/index_type/_search?pretty' -h 'content-type: application/json' -d' { "query": { "regexp": { "data": { "value": "\\@", "flags": "all" } } } } '
use "[a-za-z]+@[a-za-z]+.[a-za-z]+"
regexp find email addresses. run following query find email address
get /company/employee/_search { "query": { "regexp": { "data": { "value": "[a-za-z]+@[a-za-z]+.[a-za-z]+", "flags": "all" } } } }
here company
index, employee
type , data
field name, insert following data check query works:
post /company/employee/_bulk {"index":{"_id":"1"}} {"data":"admin@company.com"} {"index":{"_id":"2"}} {"data":"hr@company.com"} {"index":{"_id":"3"}} {"data":"webmaster@company.com"} {"index":{"_id":"4"}} {"data":"abc@company.com"} {"index":{"_id":"5"}} {"data":"ahmed@company.com"} {"index":{"_id":"6"}} {"data":"md@company.com"} {"index":{"_id":"7"}} {"data":"boss@company.com"} {"index":{"_id":"8"}} {"data":"amd@company.com"} {"index":{"_id":"9"}} {"data":"ad@company.com"} {"index":{"_id":"10"}} {"data":"ed@company.com"} {"index":{"_id":"11"}} {"data":"etc@company.com"} {"index":{"_id":"12"}} {"data":"f23f23f23f23f23 d32d23d32d d32d2 3d 23"} {"index":{"_id":"13"}} {"data":"d23d32 d32d23d32 etc@company.com d3d23d23"}
Comments
Post a Comment