Search with Lucene

Vote:
 

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?

#64442
Dec 20, 2012 14:26
Vote:
 

Figured out this is inside the IndexResponseItems property on SearchResults

#64444
Dec 20, 2012 14:59
Vote:
 

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: 

/link/001ec724ef5543f2946d9f1690f0b35a.aspx?id=4744&epslanguage=en

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 ?

#64446
Dec 20, 2012 15:38
Vote:
 

Solved it like this:

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

#64460
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.