Effective e-mail or URL link search inside text

Let's search in the content field of the documents that we have for the e-mail address :

{
  "query" : {
    "match" : {
      "content" : "malhotra@gmail.com"
      }
    }
}

Incidentally, Document 1 and Document 2 matched our query rather than just Document 1.

Let's see why this happened and how:

  • By default, the standard analyzer is taken as the default analyzer
  • The standard analyzer breaks into malhotra and gmail.com
  • The standard analyzer also breaks the e-mail ID into buygroceries and gmail.com
  • This means that when we search for the e-mail ID , either malhotra or gmail.com needs to match for the document to be qualified as a result

Hence, ...

Get Elasticsearch Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.