Query terms with dash in string?

GET /_search
{
  "query": {
    "terms": {
      "user.id": [ "kimchy", "elkbee-test" ],
    }
  }
}

Result will only include kimchy, because I guess the dash is interpretet as a bool operator. How to fix this?

Hi @Emporea Welcome to the community.

That should work... it works for me, I do notice you have an extra , at the end of you user.id line

Here is my example

DELETE discuss-test

PUT discuss-test/
{
  "mappings": {
    "properties": {
      "name": {
        "type": "keyword"
      }
    }
  }
}

POST discuss-test/_doc
{
  "name" : "kimchy"
}


POST discuss-test/_doc
{
  "name" : "stephen-test"
}

POST discuss-test/_doc
{
  "name" : "john-test"
}

GET discuss-test/_search
{
  "query": {
    "terms": {
      "name": [
        "kimchy",
        "stephen-test"
      ]
    }
  }
}

and the results

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "discuss-test",
        "_type" : "_doc",
        "_id" : "F9Cpq34Bliuj9UVF3cyX",
        "_score" : 1.0,
        "_source" : {
          "name" : "kimchy"
        }
      },
      {
        "_index" : "discuss-test",
        "_type" : "_doc",
        "_id" : "GNCpq34Bliuj9UVF3cyp",
        "_score" : 1.0,
        "_source" : {
          "name" : "stephen-test"
        }
      }
    ]
  }
}

Its not working for me. Hmm.

Edit:
Its working.
I know what I did wrong.. I didn't address the keyword field. Your answer / mappings made me realize tho!. Thanks!

=> field.keyword

What version of Elasticsearch are you on?

If you run my code above what is the result? can you show me?

Do you have smart quotes on or something?