Search Tech Design - liuninglin/pandama-ext GitHub Wiki

Reasons for Choosing Elasticsearch

  1. Not to add more complexities to our project.
  2. Best community support.
  3. Widely used for autocomplete search.

Reasons for Choosing Elasticsearch Edge N-Grams

  1. More practical for autocomplete search cases compared with Bi-Grams and Tri-Grams
  2. Match from the most left letter to the most right letter.

Diff Between Bi-Grams, Tri-Grams, and Edge N-Grams

Autocomplete Search Comparison Between Bi-Grams, Tri-Grams, and Edge N-Grams

Steps of Development:

  1. Define an edge n-grams analyzer in an existing mapping, and attach it to some fields
{
  "settings": {
    "analysis": {
      "analyzer": {
        "autocomplete": {
          "tokenizer": "autocomplete",
          "filter": [
            "lowercase"
          ]
        },
        "autocomplete_search": {
          "tokenizer": "lowercase"
        }
      },
      "tokenizer": {
        "autocomplete": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 10,
          "token_chars": [
            "letter"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "analyzer": "autocomplete",
        "search_analyzer": "autocomplete_search"
      }
    }
  }
}
  1. recreate indices for the product mapping
  2. change query logic
  3. change UI stuff