Elastic simple query with wildcard

I am new to elastic and planning to migrate my application from algolia to elastic cloud.

In algolia after creating an index and writing a document I can search by passing a search query, no need to specify wildcard patterns.
Question 1: How can achieve above behavior?

Question 2:

i.e
document data

{
  "objectID": "005klrWVvNX0RwxxX78O",
  "dn": "Root Vegetables Beetroot",
  "mq": 30,
  "desc" : "blah blah",
  "price": "150"
}

I can search for keyword "Veg" for the field "dn" and it will match this record. I dont have to mention wildcard patterns by worrying if pre and post charecters exist by specifying "Veg" or "Root*".
How can I acheive this simple search effectively?

Also I found one strange behavior,

Below search payload is not working

{
  "query": {
    "wildcard": {
      "objectID": {
        "value": "005klrWVvN*"
      }
    }
  }
}

Below search payload is working,

{
  "query": {
    "wildcard": {
      "objectID": {
        "value": "005klr*"
      }
    }
  }
}

Whats wrong with my first request?

Thank you

Hey,

take a look at different ways for indexing data, so that your search is fast, as most of the work is done on index time and not on query time. See the edge ngram token filter

hope that helps as a start!

--Alex

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