Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
How do I look ahead in searches Elastic Co

I am trying to add a search function for users in my app. When I type the word "Josh" in the search bar people with the name "Joshua" do not show up. I have type the full name "Joshua". How can I add this look-ahead functionality?

Here is my current query:

"bool": {
        "must": [
          {
            "multi_match": {
              "fields": [
                "first",
                "first.edge",
                "last",
                "last.edge",
                "title",
                "title.edge"
              ],
              "query": search,
              "fuzziness": 1,
            }
          }
        ]
      }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One way to solve it is using ngram.

PUT ngram_custom_example
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ngram_analyzer": {
          "tokenizer": "standard",
          "filter": [ "3_5_grams" ]
        }
      },
      "filter": {
        "3_5_grams": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 5
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "name":{
        "type": "text",
        "analyzer": "ngram_analyzer"
      }
    }
  }
}

POST ngram_custom_example/_bulk
{"index":{}}
{"name":"josh"}
{"index":{}}
{"name":"joshua"}

GET ngram_custom_example/_search
{
  "query": {
    "bool": {
        "must": [
          {
            "multi_match": {
              "fields": [
                "name"
              ],
              "query": "josh"
            }
          }
        ]
      }
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!