Regexp query and analyzer

Hi all,
I've to deal with searches using regex on a string field. I cannot find which is the best (if any) analyzer to be used in this case.
What I'd need is to search (also) for percentage values like 10.5%, 22.47%, etc... following the pattern provided by the UI, but the search could contain also wildcards to match one or more characters and one or more digits.

Until now I'm testing a custom analyzer defined as:

"for-regex-analyzer": {
	"type": "custom",
	"filter": ["decimal_digit"],
	"tokenizer": "whitespace"
}

where I used whitespace tokenizer and decimal_digit filter to be able to look for numbers like "10.5%" (the tokenizer preserve the "%" and the filter prevent the 10.5 to be tokenized as "10" and "5").

Then I should search for something like (e.g.) "share.{1,3} <0-9>+.<0-9>%" to match:

  • share 1%
  • share(s) 12.22%
  • shares 90%

Is it correct?

Thank you in advance for any help/idea.

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