Use regex to search the text containing dash or minus sign

Hi,

We have Elasticsearch 6.5. I am using it to search a index using regex and it is working for most of the case.

{
  "query": {
		"bool": {
			"must": [
				{
					"match": { "field1:field2" : "Complete" }
				},
				{
					"bool": {
						"should": [
							{
								"regexp": { "field1.field3" : ".*mysource_.+20190102" }
							}
						]
					}
				}
			]
		}
	},
	"size":10000
}

Using the above query is running fine for most of the cases. For e.g. mysource_121_AB_PQ_20190102 (and similar) are fetched correctly.
However, I have a text stored as mysource_101_XY-FG_20190102, which is not fetched using the above regex.

If I do not use regex, simple match fetches the data correctly. Only this regex is not working on it. I believe it is due to the hyphen or dash or minus (-) sign.

Can someone help in searching such data using the regex?

Please note the index is not maintained by us, so I cannot run admin commands on index.

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