Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

How to search Like, how to get text around

Vote:
 

1. is there way if  i search for "product" i will see results also for "products", "producting" and so on

2. is there way to get text around search key "product"

code: SearchClient.Instance.Search<IContent>().For(terms.SearchKey)

#79629
Dec 23, 2013 15:00
Vote:
 

1. See: http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Find1/75/DotNET-Client-API/Searching/Languages/
for specifying language stemming rules.

2. I don't understand the question, can you specify what you want to achieve?

/Henrik

#79791
Jan 07, 2014 11:12
Vote:
 

1. looks like didn't work

2. if i search for "product" i want to get text around the word "product" from page, like:

In marketing, a product is anything that can be offered to a market that might satisfy a want or need. In retailing

3. Also is there way to search only in page content, because if i search for "product" and my page like:

<div class="product">some text of page</div>

it will appear in search results

#80134
Edited, Jan 15, 2014 14:07
Vote:
 

If you mean by the first question that you like to have a starsearch (product*) then you have to build a extensionmethod like this one:

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;
            });
        }
    }

    

2: if you are using unified search you use [hit].Document.Excerpt, a good example by Ted on how to do that you can find here:
http://tedgustaf.com/blog/2013/10/highlight-query-matches-in-episerver-find-search-results/

3: Don't know, I guess that you are using xhtml there and the div.. are accually in the text of that property.

#82178
Mar 06, 2014 14:58
Vote:
 

Important, when update to EPiServer Find 8 you have to change the codeExample I showed, to this:

public static IQueriedSearch GraspingRightHandTruncationFor(this ITypeSearch search, string queryString)
        {
            if (search == null)
            {
                throw new ArgumentNullException("search");
            }
            
            var str = (string.IsNullOrWhiteSpace(queryString) ? "" : queryString);

            str += !str.Contains("\"") ? "*" : "";

            return new Search(search, (ISearchContext context) =>
            {
                var queryStringQuery = new QueryStringQuery(str);
                queryStringQuery.RawQuery = queryString;
                var queryStringQuery1 = queryStringQuery;
                context.RequestBody.Query = queryStringQuery1;
            });
        }

Otherwise there will not register any statistics with the search.

#89155
Aug 08, 2014 12:53
* 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.