Index numbers in strings as numeric and words

Hi, I have a requirement where I want to search for numbers within a string by both the numeric value (e.g. 3) and the string value (e.g. "three").

For example given the following index configuration

PUT number-test
{
  "mappings": {
    "properties": {
      "text": {
        "type": "text", 
        "analyzer": "standard"
      }
    }
  }
}

PUT number-test/_doc/1
{
  "text": "this is the number three"
}

PUT number-test/_doc/2
{
  "text": "this is the number 3"
}

PUT number-test/_doc/3
{
  "text": "this is the number 2"
}

PUT number-test/_doc/4
{
  "text": "this is the number two"
}

Then the following search would return both documents 1 & 2.

POST number-test/_search
{
  "query": {
    "match": {
      "text": "three"
    }
  }
}

I know I could probably achieve this via synonyms. But I was hoping there was an automated way to do it (maybe through an additional tokenizer etc) that wouldn't require me having to configure every possible number as a synonym.

Thanks

I don't think there is another solution than the synonyms or a Pattern replace.

May be using the new Machine Learning features for text would work though. But note that is part of the commercial license.

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