November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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
Hi Skuseth,
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 World
1) 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.
Thanks.
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;
return client.Search<ISearchContent>(language).GraspingRightHandTruncationFor<ISearchContent>(query).WithAndAsDefaultOperator().InAllField();
}
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
Hi,
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.
Can you please check my code and leave your suggestions here.
Many Thanks.
Kishore T.