My question might be simple but your sugestions can save a lot of time for me.
I'm trying to get the results from all the indexes if a string or part of the string is exist in the document.
I tried MoreLike method which is described in documentation, but unfortunately that is not working.
ITypeSearch<ImageVaultNonDoc> query = client.Search<ImageVaultNonDoc>()
.Filter(x => x.AlbumId.In(lstImageVaultAlbums));
var results = query.MoreLike(Query).OrderByDescending(orderby => orderby.CreatedDate)
.Select(x2 => new ImageVaultFiles
Id = x2.Id,
Name = x2.Name,
PortalTitle = x2.PortalTitle,
AlbumId = x2.AlbumId
.IncludeType<ImageVaultFiles, ImageVaultDoc>(x1 => new ImageVaultFiles
Id = x1.Id,
Name = x1.Name,
PortalTitle = x1.PortalTitle,
AlbumId = x1.AlbumId
Can you please check my code and leave your suggestions here.
Hi!Why not simply use .For()? Or do you need to get hits on parts of words? If that is the case, then perhaps a wildcard search is what you need. Or, perhaps .PreFix or .AnyWordBeginsWith ? http://find.episerver.com/Documentation/dotnet-api-filtering-strings
Thanks for your reply.
.For() is working fine enough if the complete wordis matched, but not if the part of the word is matched.
Below is my requirement:
Keywords: Hello World1) Result: Bring back anything contains "HELLO" or "WORLD". If the result contains not the exact word such as "HELLOMYFRIEND" or "WELCOMETOMYWORLD", they are considered hit too and should be brought back.
2) The above searching should happen over the entire indexes but not limited to any specefic field (similar to how we user For() )
So, because of point no(2), I can't use Wild Card search also.
Any other ideas please.
Any particular reason why you would want to search across all fields? If you do that, then you may get a match on hits you do not wish for. For example, in your case, if you wild card search across all fields, with query set to "Image", you would get a match on every hit, as it would get a hit on the "type" field, which is "ImageVaultNonDoc" in this case. I would recommend that you do specify the fields. Doing a wild card search across all the fields does not sound like a good idea performance wise.I would suggest that you use wild card search and specify the fields.Optionally, you could create an extension method that will return all string based properties, and then index that. You could then do a wild card search against that single field. The last method migth be better performance wise as well.
I hope this helps! :-)
Here is a extension we use to do a word*-search on all field.
public static class SearchExtensions
public static IQueriedSearch<ISearchContent> UnifiedSearchGraspingRightHandTruncationFor(this IClient client, string query, Language language)
language = language ?? Language.None;
public static IQueriedSearch<TSource, QueryStringQuery> GraspingRightHandTruncationFor<TSource>(this ITypeSearch<TSource> search, string queryString)
if (search == null)
throw new ArgumentNullException("search");
var str = (string.IsNullOrWhiteSpace(queryString) ? "" : queryString);
str += !str.Contains("\"") ? "*" : "";
return new Search<TSource, QueryStringQuery>(search, (ISearchContext context) =>
var queryStringQuery = new QueryStringQuery(str);
context.RequestBody.Query = queryStringQuery;
Henrik's code should work, you just need to add a * to the start of the query, so that you'll get a *word*-search working. I would still suggest specifying fields though :-D