Hella
Hella

Reputation: 5

Query DSL regexp pattern doesn't work with some strings

I have a pattern ".TP-V." which returns strings like "SSTP-VPN". But the pattern ".SSH." Does not return anything, although there are lines like "core:Login:SSH:Cisco". I have no idea what pattern is need.

Upvotes: 0

Views: 1767

Answers (1)

Bhavya
Bhavya

Reputation: 16172

You need to use ".*SSH.*" instead of ".SSH.". Adding a working example -

Index Data:

{
    "name":"core:Login:SSH:Cisco"
}
{
    "name":"SSTP-VPN"
}

Search Query:

{
  "query": {
    "regexp": {
      "name.keyword": {
        "value": ".*SSH.*"
      }
    }
  }
}

Search Result:

"hits": [
      {
        "_index": "68015371",
        "_type": "_doc",
        "_id": "2",
        "_score": 1.0,
        "_source": {
          "name": "core:Login:SSH:Cisco"
        }
      }
    ]

Search Query:

{
  "query": {
    "regexp": {
      "name.keyword": {
        "value": ".*TP-V.*"
      }
    }
  }
}

Upvotes: 1

Related Questions