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

Episerver Find Wildcard search doesn't return expected results

Vote:
 

Recently I've been experimenting with EPiServer Find, I'm trying to figure out how wildcard queries are used.

I am encountering the following difficulty:

One of my colleagues has set up a POC with EPiServerFind, sadly this only searches for the entire word. For example: If you search 'applepie' you will find the page but searching 'apple' or 'pie' won't find the page. I've looked into wildcard queries to solve this, however I get unexpected results when I use them.

Details Like I've pointed out earlier, whenever I query EPiServerFind I get only full word matches.

var basicSearch = _client.Search()
    .For(q)
        .InFields(x => x.Name, x => x.SearchTitle(), x => x.SearchText())
        .InAllField()
    .ExcludeContainerPages()
    .ExcludeContentFolders()
    .ExcludeDeleted()
    .GetContentResult()
    .Select(CreateSearchHitViewModel)
    .Where(x => x != null);

I've used an article of Joel Abrahamsson to help me with the implementation of the wildcard query:

var wildcardSearch = _client.Search()
    .WildCardQuery(String.Format("*{0}*", q), x => x.Name)
    .WildCardQuery(String.Format("*{0}*", q), x => x.SearchTitle())
    .WildCardQuery(String.Format("*{0}*", q), x => x.SearchText())
    .ExcludeContainerPages()
    .ExcludeContentFolders()
    .ExcludeDeleted()
    .GetContentResult()
    .Select(CreateSearchHitViewModel)
    .Where(x => x != null);

I've used this blog: http://joelabrahamsson.com/wildcard-queries-with-EPiServer-find/

Sadly I get unexpected results when I use this. I get a few unrelated results but more of the relevant results are completely ignored.

I have no clue as to where this is failing and I hope someone can tell me.

Thank you in advance.

#121359
May 07, 2015 14:02
Vote:
 

Hi, it seems like you can do something like:

.For(searchTerm, q =>
{
q.Query = searchTerm + "*";
}).InField(x => x.Name)

Works fine when I try it locally. Good luck. :)

#121373
May 07, 2015 15:43
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.