@carlosjimenezdev To achieve what you are looking for you would have to handle the arithmetic conversion on application level, before indexing/searching, making sure that only decimal values are sent to Opensearch (.25 instead of 1/4). Opensearch can then do the necessary processing using analysers to remove the additional “inch”, “in” and quotes, thereby indexing and searching only using the decimal notation. See example below:
PUT /industrial_tools4
{
"settings": {
"analysis": {
"char_filter": {
"unit_strip": {
"type": "pattern_replace",
"pattern": "(?i)\\s*(inch(?:es)?|in|\u2033|\u0022|\u0027|\u201c|\u201d)\\s*",
"replacement": ""
},
"leading_dot_fix": {
"type": "pattern_replace",
"pattern": "(?<![0-9])\\.([0-9]+)",
"replacement": "0.$1"
}
},
"analyzer": {
"dimension_analyzer": {
"type": "custom",
"char_filter": ["unit_strip", "leading_dot_fix"],
"tokenizer": "whitespace",
"filter": ["lowercase"]
}
}
}
},
"mappings": {
"properties": {
"sku": { "type": "keyword" },
"product_name": { "type": "text", "analyzer": "standard" },
"product_type": { "type": "text", "analyzer": "standard", "fields": { "keyword": { "type": "keyword" } } },
"dimensions_catchall": { "type": "text", "analyzer": "dimension_analyzer" },
"popularity_score": { "type": "float" },
"is_featured": { "type": "boolean" },
"sales_rank": { "type": "float" },
"cutter_diameter_str": {
"type": "text",
"analyzer": "dimension_analyzer",
"copy_to": "dimensions_catchall",
"fields": { "keyword": { "type": "keyword" } }
},
"shank_diameter_str": {
"type": "text",
"analyzer": "dimension_analyzer",
"copy_to": "dimensions_catchall",
"fields": { "keyword": { "type": "keyword" } }
},
"overall_length_str": {
"type": "text",
"analyzer": "dimension_analyzer",
"copy_to": "dimensions_catchall",
"fields": { "keyword": { "type": "keyword" } }
},
"flute_length_str": {
"type": "text",
"analyzer": "dimension_analyzer",
"copy_to": "dimensions_catchall",
"fields": { "keyword": { "type": "keyword" } }
}
}
}
}
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": ".25" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25\"" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25in" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25in" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25 inch" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25 inches" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25\u2033" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25\u201c" }
GET /industrial_tools4/_analyze
{ "analyzer": "dimension_analyzer", "text": "0.25\u201d" }
Hope this helps