Try our conversational search powered by Generative AI!

Find through pages of Page Types created through admin mode

Vote:
 

I'm working on to implement the Free-Text-Search in my EPiServer 6R2 site. I have downloaded the latest Find.EPiServer dlls - EPiServer.Find, EPiServer.Find.CMS, EPiServer.Find.Framework and Newtonsoft.Json from "http://world.episerver.com/Download/Items/EPiServer-Find/EPiServer-Find-1-R2/" and referenced the same in my solution.I have gone through the samples in mentioned http://find.episerver.com/Documentation/dotnet-api-free-text-search.
 However, I believe that all these methods can be implemented only when the Page Types are created through Page-Builder. When we want to search through pages that are created through admin mode, we got to use the method ".InField(x => x.SearchText())", so that the fields that are marked as searchable can be queried upon. However, I not able to find the x.SearchText() method under "EPiServer.Find" namespace. Can any one let me know the namespace that I need to add in order to find the SearchText method. Also I would like to know the options available to implement the Free-Text-Search for pages of Page Types that are created through admin mode. Thank you.

/Rajesh B

#62836
Nov 05, 2012 11:27
Vote:
 

Hi,

SearchText is an extension method for PageData and you can do InField(x => x.SearchText()) IF you are searching for PageData, ie:

SearchClient.Instance.Search<PageData>()
.For("something")
.InField(x => x.SearchText()) //x is of type PageData
.GetPagesResult();

If you can't get it to work, please paste your code here.

#62946
Nov 05, 2012 17:56
Vote:
 

Hi,

I have pasted my code below:

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

usingSystem.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using EPiServer;using EPiServer.Core;

using EPiServer.DataAbstraction;

using EPiServer.Web.WebControls;

using EPiServer.Find;

namespace EPiServer

{

publicpartialclassFindEPiServer : EPiServer.TemplatePage

{

protectedIClient client = Client.CreateFromConfig();protectedvoid Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

Search();

}

}

protectedvoid Search()

{

var result = client.Search<PageData>().For("about-us").InField(x => x.SearchText()).GetResult();

}

}

}

However, on compiling I get the following error:

'EPiServer.Core.PageData' does not contain a definition for 'SearchText' and no extension method 'SearchText' accepting a first argument of type 'EPiServer.Core.PageData' could be found (are you missing a using directive or an assembly reference?)

#62953
Nov 06, 2012 7:59
Vote:
 

You're missing a using statement:

using EPiServer.Find.Cms;

 

Also, instead of Client.CreateFromConfig, use SearchClient.Instance.

Read more on the EPiServer/CMS integration here.

#62954
Nov 06, 2012 8:11
Vote:
 

Hi Joel,

I have "EPiServer.Find.Cms" now and the following query returns the results:

var result = SearchClient.Instance.Search<PageData>().For(Query).InField(x => x.SearchText()).GetResult()

Thank you for your help.

 

#63077
Edited, Nov 08, 2012 15:18
* 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.