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

Episerver Find autocomplete

Vote:
 

Hello guys, 

I'm currently working on an autocomplete function within Episerver Find. I've seen some solutions already, but none of them seem to work for the case I want it to. 

I have a working autocomplete, but this autocomplete does not take into account the best bets, which I would like on top of the autocomplete return. The best bets are external urls and don't seem to work with PageData.

The current solution:

        public static SearchResults AutoComplete(string q)
        {
            var result = SearchClient.Instance.Search()
                .ApplyBestBets()
                .Filter(x => x.Name.PrefixCaseInsensitive(q))
                .Select(x => x.Name)
                .StaticallyCacheFor(TimeSpan.FromHours(1))
                .GetResult();

            return result;
        }

The solution I'm working on aswell (Where instead of the best bet, I'm struggling on the filters for autocomplete):

        public static IEnumerable AutoComplete2(string q)
        {
            var result = SearchClient.Instance.UnifiedSearchFor(q)
                .ApplyBestBets()
                .StaticallyCacheFor(TimeSpan.FromHours(1))   
                // Can't seem to get working filters here.
                .GetResult()
                .Select(x => new SearchItem(x))

            return result;
        }

Any feedback is appreciated!

#184450
Edited, Oct 27, 2017 11:33
Vote:
 

You can try ApplyBestBets() after the filters and before GetResults() (or caching). The filters may be fitlering out the best bets?

#184493
Oct 28, 2017 20:08
Vote:
 

Hey David, thank you for your response and sorry for the late reaction.

I've tried your solution, however it doesn't seem to change the outcome of the function. I'm still searching for a solution for an autocomplete with bestbest included.

Paul

#184652
Nov 01, 2017 11:44
* 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.