November Happy Hour will be moved to Thursday December 5th.

EPiServer Find Auto Suggest

Vote:
 

Hi,

I have a question reagrding search suggestions.

Is it possible to implement auto suggest using EPiServer Find?

I checked the Find SDK and there is an example for auto complete which is totally understandable.

I just want to know if it is possible to suggest variants without doing a search.

Thank you.

#117284
Feb 16, 2015 21:41
Vote:
 

Hello Islam

Using Find to provide autocomplete search results is certainly possible. The code below can be used to provide a suggested list of results for Name property of the Foo type:

public JsonResult Prefix(string term)
{
    var results = client.Search<Foo>()
        .Filter(x => x.Name.PrefixCaseInsensitive(term))
        .Select(x => x.Name)
        .StaticallyCacheFor(TimeSpan.FromHours(1))
        .GetResult();

    return Json(results.Select(x => x), JsonRequestBehavior.AllowGet);
}

Simply add the code above to a controller to use in your client side javascript.

David

#117286
Feb 17, 2015 0:28
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.