Implementing search with Ajax What is the best way to implement a typeahead search in Craft. I looked at using ElementAPI to do something similar at this example but it doesn't seem to allow me to wildcard search

https://craftcms.com/docs/templating/search-form

Here's an example of the endpoints I have configured:

I have one entry with a title of "test" when I call the API doing 

When I call /entries/te its returns 0 results. When I call /entries/test it returns 1 result.

&lt;?php

namespace Craft;
return [
    'endpoints' =&gt; [

        'entries/&lt;search:\w+&gt;' =&gt; function($search) {
            return [
                'elementType' =&gt; 'Entry',
                'criteria' =&gt; ['title' =&gt; $search]
            ];
        }

    ]
];
If you want to enable fuzzy searching globally (across the entire Craft install - CP, front-end, ElementAPI, etc.), you can use the defaultSearchTerms config setting.

You can also just do it programmatically from the ElementAPI plugin with something like:

Suffix wildcard:

'criteria' =&gt; ['title' =&gt; $search ~ '*']


Prefix wildcard:

'criteria' =&gt; ['title' =&gt; '*' ~ $search]


Both sides:

'criteria' =&gt; ['title' =&gt; '*' ~ $search ~ '*']


Or you can use any of the other search syntaxes listed on the search docs page.