title: How do I implement a PatternAnalyzer in elastic4s and elasticsearch to exclude result with a certain field
body: <p>I'm trying to perform a query on my index and get all reviews that do NOT have a reviewer with a gravatar image. To do this I have implemented a PatternAnalyzerDefinition with a host pattern: </p>
  
  <pre><code>"^https?\\:\\/\\/([^\\/?#]+)(?:[\\/?#]|$)"
  </code></pre>
  
  <p>that should match and extract host of urls like:</p>
  
  <p><a href="https://www.gravatar.com/avatar/blablalbla?s=200&amp;r=pg&amp;d=mm" rel="nofollow">https://www.gravatar.com/avatar/blablalbla?s=200&amp;r=pg&amp;d=mm</a></p>
  
  <p>becomes:</p>
  
  <pre><code>www.gravatar.com
  </code></pre>
  
  <p>The mapping:</p>
  
  <pre><code>clientProvider.getClient.execute {
            create.index(_index).analysis(
              phraseAnalyzer,
              PatternAnalyzerDefinition("host_pattern", regex = "^https?\\:\\/\\/([^\\/?#]+)(?:[\\/?#]|$)")
            ).mappings(
  "reviews" as (
               .... Cool mmappings
                "review" inner (
                  "grade" typed LongType,
                  "text" typed StringType index "not_analyzed",
                  "reviewer" inner (
                    "screenName" typed StringType index "not_analyzed",
                    "profilePicture" typed StringType analyzer "host_pattern",
                    "thumbPicture" typed StringType index "not_analyzed",
                    "points" typed LongType index "not_analyzed"
                  ),                    
                 .... Other cool mmappings                    
                )
              ) all(false)
  } map { response =&gt;
        Logger.info("Create index response: {}", response)
      } recover {
        case t: Throwable =&gt; play.Logger.error("Error creating index: ", t)
      }
  </code></pre>
  
  <p>The query:</p>
  
  <pre><code>val reviewQuery = (search in path)
        .query(
          bool(
            must(
              not(
                termQuery("review.reviewer.profilePicture", "www.gravatar.com")
              )
            )
          )
        )
        .postFilter(
          bool(
            must(
              rangeFilter("review.grade") from 3
            )
          )
        )
        .size(size)
        .sort(by field "review.created" order SortOrder.DESC)
  
      clientProvider.getClient.execute {      
        reviewQuery
      }.map(_.getHits.jsonToList[ReviewData])
  </code></pre>
  
  <p>Check the index for the mapping:</p>
  
  <pre><code>reviewer: {
      properties: {
          id: {
              type: "long"
          },
          points: {
              type: "long"
          },
          profilePicture: {
              type: "string",
              analyzer: "host_pattern"
          },
          screenName: {
              type: "string",
              index: "not_analyzed"
          },
          state: {
              type: "string"
          },
          thumbPicture: {
              type: "string",
              index: "not_analyzed"
          }
      }
  }
  </code></pre>
  
  <p>When i perform the query the pattern matching does not seem to work. I still get reviews with a reviewer that has a gravatar image.
  What am I doing wrong? Maybe I have misunderstood the PatternAnalyzer?</p>
  
  <p>I'm using
  "com.sksamuel.elastic4s" %% "elastic4s" % "1.5.9",</p>