Query dsl, must and must_not

I have a
version: v100.01
version: v100.01.xyz

how do I only match v100.01 either using regexp or wildcard

following both query gives me both result

{
    "query": {
        "regexp": {  "version": "v<0-9><0-9><0-9>.<0-9><0-9>"  }
    }
}

{
  "query": { 
    "wildcard": {  "version": "v???.??"    }
    }
}

Sachin,
What is the type of the version field? text or keyword? Both queries should work if type is keyword.

If type is text the regex pattern you are using will be applied to each token.

that is it. I was not using keyword.
I have this working like this now.

{
  "query": {
    "bool": {
      "must_not": [
        {
          "wildcard": { "version.keyword": "v???.??.???" }
        }
      ],
      "must": [
        {
          "regexp": { "version.keyword": "v<0-9><0-9><0-9>.<0-9><0-9>" }
        }
      ]
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.