Exact match for string field

  1. Create an index with an explicit mapping.
  2. Make each field which needs to answer exact string searches a Keyword field

Titles are an unusual choice for a keyword field. Isn't contentid already unique per record? Even if I had to sometimes search by title, I would usually only search for contentid or title in any one query.

Still, if you really want exact string matches for both, make them both keyword fields and then issue Term queries on them.

Finally, a more flexible mapping would be to allow title to be used both for searching for individual words, and full exact matches. This also takes up more space. If you only ever want exact string matches, delete the fields part of the title mapping.

{
  "mappings": {
    "properties": {
      "contendid": {
        "type":  "keyword"
      },
      "title": {
        "type":  "text",
        "fields": {
          "raw": { 
            "type":  "keyword"
          }
        }
      }
    }
  }
}

With that mapping, issue Term queries to contentid and title.raw, but issue any of the full text queries to title (simplest are Match and Query String).