Search with Lucene


I am using the built-in search in EPiServer, and so far so good. However I need to display the part of the page that matches the query. For instance: A user searches for "water" and in one page the match is "it is water in the ocean" , I want to display:

1) title of the page

2) the text where the search matched.


Is this possible?

Dec 20, 2012 14:26

Figured out this is inside the IndexResponseItems property on SearchResults

Dec 20, 2012 14:59

A bit of a follow-up here: Through the IndexResponseItem I am able to extract DisplayText and Title, When I then try to fetch a link to the result through the Uri property I only get strings on this format: 


Earlier I used :

var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();

urlResolver.GetVirtualPath(someContentReference here); <-- giving me a nice url like :/production/myitem/

However, I dont have a contentreference for the result. Any suggestions ?

Dec 20, 2012 15:38

Solved it like this:

string myUrl =  urlResolver.GetVirtualPath(contentSearchHandler.GetContent<PageData>(item).ContentLink)

Dec 20, 2012 16:38
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.