Which is better in terms of performance? one wildcard or six matches

Hello

Based on the words searched by the user, I want to prioritize products whose matched words are closer to the beginning of the product name.

For example, if we have two products as follows

"Samsung mobile phone cover"
"TypeC charger with fast charging capability for Samsung mobile phone"

And the user searches for the word "Samsung mobile phone".
First comes the "Samsung phone cover" and then the "Type C charger with fast charging capability for the Samsung mobile phone".

To do this, I have two methods in mind and I want to know which of the following two methods works better performance in the number of requests from approximately 1000 to 5000 per 30 secound.

Note: My products name is between 6 characters and 9 characters

The first method:
Use wildcard (this method is less accurate than the following method)
code:

{
  "query": {
    "bool": {
      "should": [
        {
          "wildcard": {
            "name.keyword": {
              "value": "example*"
            }
          }
        }
      ]
    }
  }
}

The second method:
I store the first to sixth words of each product separately in a sub feild, and the closer the searched word is to the first product name, the more points it gets.

Note: Only one word is placed in each subfield

code:

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "name.word_one": {
              "query": "example",
              "boost": 6
            }
          }
        },
        {
          "match": {
            "name.word_two": {
              "query": "example",
              "boost": 5
            }
          }
        },
        {
          "match": {
            "name.word_tree": {
              "query": "example",
              "boost": 4
            }
          }
        },
        {
          "match": {
            "name.word_four": {
              "query": "example",
              "boost": 3
            }
          }
        },
        {
          "match": {
            "name.word_five": {
              "query": "example",
              "boost": 2
            }
          }
        },
        {
          "match": {
            "name.word_six": {
              "query": "example",
              "boost": 1
            }
          }
        }
      ]
    }
  }
}

mapping :

{
  "setting": {
    "analysis": {
      "analyzer": {
        "word_one": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "other fiters",
            "word_one_filter"
          ]
        },
        "word_two": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "other fiters",
            "word_two_filter"
          ]
        },
        "word_tree": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "other fiters",
            "word_tree_filter"
          ]
        },
        "word_four": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "other fiters",
            "word_four_filter"
          ]
        },
        "word_five": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "other fiters",
            "word_five_filter"
          ]
        },
        "word_six": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "other fiters",
            "word_six_filter"
          ]
        }
      },
      "filter": {
        "word_one_filter": {
          "type": "predicate_token_filter",
          "script": {
            "source": "token.getPosition() === 0"
          }
        },
        "word_two_filter": {
          "type": "predicate_token_filter",
          "script": {
            "source": "token.getPosition() === 1"
          }
        },
        "word_tree_filter": {
          "type": "predicate_token_filter",
          "script": {
            "source": "token.getPosition() === 2"
          }
        },
        "word_four_filter": {
          "type": "predicate_token_filter",
          "script": {
            "source": "token.getPosition() === 3"
          }
        },
        "word_five_filter": {
          "type": "predicate_token_filter",
          "script": {
            "source": "token.getPosition() === 4"
          }
        },
        "word_six_filter": {
          "type": "predicate_token_filter",
          "script": {
            "source": "token.getPosition() === 5"
          }
        }
      }
    }
  },
  "mappings": {
    "name": "text",
    "fields": {
      "keyword": {
        "type": "keyword"
      },
      "word_one": {
        "type": "text",
        "analyzer": "word_one"
      },
      "word_two": {
        "type": "text",
        "analyzer": "word_two"
      },
      "word_tree": {
        "type": "text",
        "analyzer": "word_tree"
      },
      "word_four": {
        "type": "text",
        "analyzer": "word_four"
      },
      "word_five": {
        "type": "text",
        "analyzer": "word_five"
      },
      "word_six": {
        "type": "text",
        "analyzer": "word_six"
      }
    }
  }
}

tip: My data is about 200 million documents

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