Wildcard-like search on synonym authorizer

Currently facing an issue with synonyms and using Elasticsearch managed service not self hosted elasticsearch

I have created a synonym file and created an authorizer that utilizes this synonym file in a filter

PUT /store-channels/_settings
{
    "analysis": {
      "filter": {
        "synonym_store_filter": {
          "type": "synonym",
          "synonyms_path": "synonyms-stores.txt",
          "updateable": true
        },
        "synonym_product_filter": {
          "type": "synonym",
          "synonyms_path": "synonyms-products.txt",
          "updateable": true
        }
      },
      "analyzer": {
        "lowercase_analyzer": {
          "tokenizer": "whitespace",
          "filter": ["lowercase"]
        },
        "synonym_store_analyzer": {
          "tokenizer": "whitespace",
          "filter": ["lowercase", "synonym_store_filter"]
        },
        "synonym_product_analyzer": {
          "tokenizer": "whitespace",
          "filter": ["lowercase", "synonym_product_filter"]
        }
      }
    }
}

the synonym works when the value is equal but not like so either the value has to be exact or no value at all. According to the elasticsearch documentation that authorizers bypass wildcard operations so you cannot use wildcard on an authorizer property

example:
I have in my store channels several stores but I want to search for KFC, in my synonym file for store channels I have "kfc , kentucky fried chicken" which if you search for "kentucky fried chicken" it is getting KFC but if the store channel name is "KFC Enoc Tower" or "KFC Barsha Mall" that the synonym authorizer is ignoring those values and just getting store channels that have "KFC" in them

I tried using edge-ngram which gets the places that contain "KFC" but it also gets other places that contain "fried" and "chicken" when you search for "kentucky fried chicken" since the edge-ngram will cut the word for you, while it does the job and gets all the "KFC" like named places yet the additional store channels that I do not need like "Fried and Stuff" and "Chicken way"

here is a sample of my edge-ngram

PUT /store-channels/_settings
{
  "analysis": {
    "tokenizer": {
      "edge_ngram_tokenizer": {
        "type": "edge_ngram",
        "min_gram": 2,
        "max_gram": 10,
        "token_chars": [
          "letter",
          "digit"
        ]
      }
    },
    "filter": {
      "synonym_store_filter": {
        "type": "synonym",
        "synonyms_path": "synonyms-stores.txt",
        "updateable": true
      },
      "synonym_product_filter": {
        "type": "synonym",
        "synonyms_path": "synonyms-products.txt",
        "updateable": true
      }
    },
    "analyzer": {
      "lowercase_analyzer": {
        "tokenizer": "whitespace",
        "filter": [
          "lowercase"
        ]
      },
      "synonym_store_edge_ngram_analyzer": {
        "type": "custom",
        "tokenizer": "edge_ngram_tokenizer",
        "filter": [
          "lowercase",
          "synonym_store_filter"
        ]
      },
      "synonym_product_edge_ngram_analyzer": {
        "type": "custom",
        "tokenizer": "edge_ngram_tokenizer",
        "filter": [
          "lowercase",
          "synonym_product_filter"
        ]
      }
    }
  }
}

The problem that I couldn't use post filtering because I have lots of records and I cannot assume what will the user search for so that I can do post filtering since I might filter out something that the user explicitly might want (back to the "KFC" example that I cannot post filter "chicken" and "fried" because I cannot assume what the user might search for maybe he/she wants to search for places that does contain chicken or fried plus this issue happened with not just KFC but McDonalds and Costa Coffee where you can find "McDonald's Enoc Tower")

so is there a way to use synonyms and get searches that are like the synonym not exact in elasticsearch?

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