Query based string to match a regular expression

Hello,

I know it is possible to make a regular expression query to match any string in a string based document on elasticsearch. But is it possible the other way around ? Can I make a query based on a string and match a regular expression saved in the document with elasticsearch ?

For instance, I create the following document via kibana :

POST /test1/type
{
  "input": "[0-9]+ ?kg",
  "output": "weight"
  
}

Can I make a query with the string "67kg" in order to match the regex and get this :

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test1",
        "_type" : "type",
        "_id" : "XqXucGgBXOzlaMdqiLcI",
        "_score" : 1.0,
        "_source" : {
          "input" : "[0-9]+ ?kg",
          "output" : "weight"
        }
      }
    ]
  }
}

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