Customized the Search result page template

Posted by Community Admin on 04-Aug-2018 06:30

Customized the Search result page template

All Replies

Posted by Community Admin on 11-Jan-2012 00:00
Hi,
Can i modify the the result page and add thumbnail for each search result in sitefinity 4.3.?

Please help.
Thanks

Posted by Community Admin on 13-Jan-2012 00:00
Hi Shalaka,

Could you please elaborate about the thumbnail bit? If you have News search results what kind of thumbnails will you display? Please give us more details on the matter.

Greetings,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Posted by Community Admin on 13-Jan-2012 00:00
Hi,
I want to create a search result page which will show the news search result along with the news thumbnail field.
Currently the search result page shows URL and news heading. I want to show custom fields also.
Is it possible?
Please help.
Thanks.
Posted by Community Admin on 16-Jan-2012 00:00
Hi Shalaka,

Please review the following blog posts related to the search:

http://www.sitefinity.com/blogs/teodorgeorgiev/posts/11-11-14/search_index_with_custom_fields_in_sitefinity_4.aspx 

http://www.sitefinity.com/blogs/teodorgeorgiev/posts/11-09-07/adding_a_new_content_type_to_search.aspx 

http://www.sitefinity.com/blogs/ivanpelovski/posts/11-08-16/registering_custom_pipes_in_sitefinity.aspx 

I hope this helps.

All the best,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Posted by Community Admin on 20-Jan-2012 00:00
i refereing to this post given by you - p://www.sitefinity.com/blogs/teodorgeorgiev/posts/11-11-14/search_index_with_custom_fields_in_sitefinity_4.aspx 
Where should i write this code.
I have created one custom filed in news. and i want to add that filed in search result.
I need both the cases
1 . Want to search based on the custom field
2.. want to search on default fields and show the custom field in search result page.


Please help
Thanks.
Posted by Community Admin on 23-Jan-2012 00:00
Hi,
I have created a new project called 'CustomSearch' and added following three classes in that .
I have created dll of this customsearch and added in my sitefinitywebsite. Then i created a provider by specifying type as " CustomSearch.LuceneSearchProviderNew" and change my default search provder name to  "CustomSearch"
I am getting 'Exception Throwsw By The Target Of Invocation' error while doing reindexing.
and the attached error while doing search from frontend.

Please see the code and help.


1)  ContentInboundPipeNew.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Sitefinity.Publishing.Pipes;
using Telerik.Sitefinity.Publishing;
using Telerik.Sitefinity.Publishing.Translators;
using Telerik.Sitefinity.Services.Search.Publishing;

namespace CustomSearch

public class ContentInboundPipeNew : ContentInboundPipe

public override Telerik.Sitefinity.Publishing.Model.PipeSettings PipeSettings

get

var settings = base.PipeSettings;
var mappings = settings.Mappings.Mappings;
var customField = "TestSearch";
var customFieldMapping = PublishingSystemFactory.CreateMapping(customField, ConcatenationTranslator.TranslatorName, true, customField);
if(!mappings.Contains(customFieldMapping))
mappings.Add(customFieldMapping);

return settings;

set

base.PipeSettings = value;






public class SearchIndexOutboundPipeNew : SearchIndexOutboundPipe

public override Telerik.Sitefinity.Publishing.Model.PipeSettings PipeSettings

get

var settings = base.PipeSettings;
var mappings = settings.Mappings.Mappings;
var customField = "TestSearch";
var customFieldMapping = PublishingSystemFactory.CreateMapping(customField, ConcatenationTranslator.TranslatorName, true, customField);
if (!mappings.Contains(customFieldMapping))
mappings.Add(customFieldMapping);

return settings;

set

base.PipeSettings = value;









2 )  LuceneCustomResultSet.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Sitefinity.Services.Search.Data;
using System.IO;
using Telerik.Sitefinity.Utilities.Lucene.Net.QueryParsers;
using Telerik.Sitefinity.Utilities.Lucene;
using Telerik.Sitefinity.Publishing.Model;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Utilities.Lucene.Net.Search;
using System.Globalization;
using Telerik.Sitefinity.Services.Search;
using Telerik.Sitefinity.Utilities.Lucene.Net.Index;


namespace CustomSearch

public class LuceneCustomResultSet : LuceneResultSet


public LuceneCustomResultSet(LuceneSearchProvider provider, string catalogueName, string query, params string[] orderBy)
: this(provider, catalogueName, query, 0, 0, orderBy)




string catalogueName = String.Empty;
public LuceneCustomResultSet(LuceneSearchProvider provider, string catalogueName, string query, int skip, int take, params string[] orderBy)
: base(provider, catalogueName, query, 0, 0, orderBy)

this.catalogueName = catalogueName;
this.query = query;


protected override void ExecuteQuery(bool tryToFix = true)

try

var path = ((LuceneSearchProvider)SearchManager.GetManager("").Provider).GetCataloguePath(catalogueName);
if (System.IO.Directory.Exists(path))

var defautlOperator = QueryParser.AND_OPERATOR;
var analyzer = this.GetAnalyzer();

var parser = new MultiFieldQueryParser(new string[] "Title", "Content", "TestField" , analyzer);
parser.SetDefaultOperator(defautlOperator);

//query = QueryParser.Escape(query);


if (searcher != null)
searcher.Close();

searcher = new IndexSearcher(path);
Query queryObj = searcher.Rewrite(parser.Parse(query));
Query = queryObj;

//Search only for current language
if (AppSettings.CurrentSettings.Multilingual == true)

TermQuery languageQuery = new TermQuery(new Term("Language", CultureInfo.CurrentUICulture.Name));
TermQuery languageNullQuery = new TermQuery(new Term("Language", SearchProvider.FieldNullValue));

BooleanQuery filterQuery = new BooleanQuery();
filterQuery.Add(languageQuery, BooleanClause.Occur.SHOULD);
filterQuery.Add(languageNullQuery, BooleanClause.Occur.SHOULD);

QueryFilter languageFilter = new QueryFilter(filterQuery);

this.hits = searcher.Search(queryObj, languageFilter);

else

this.hits = searcher.Search(queryObj);


for (var iter = 0; iter < this.HitCount; iter++)

var doc = this.hits.Doc(iter);



catch (Exception ex)

if (tryToFix && ex is ParseException)

this.query = this.TryFixQuery(this.query);
this.ExecuteQuery(false);

else

this.error = ex;
this.hits = null;




private Exception error;
private string query;
private IndexSearcher searcher;
public void Dispose()

if (this.searcher != null)

this.searcher.Close();
this.searcher = null;





3)  LuceneSearchProviderNew.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.Services.Search.Data;

namespace CustomSearch

class LuceneSearchProviderNew : LuceneSearchProvider


public override IResultSet Find(string catalogueName, string query, int skip, int take, params string[] orderBy)

return new LuceneCustomResultSet(this, catalogueName, query, skip, take, orderBy);


public override IResultSet Find(string catalogueName, string query, params string[] orderBy)

return new LuceneCustomResultSet(this, catalogueName, query, orderBy);




Posted by Community Admin on 24-Jan-2012 00:00
Hello Shalaka,

Please make your "LuceneSearchProviderNew" class public. This is what causes this exception.

Greetings,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Posted by Community Admin on 02-Feb-2012 00:00
Thanks.
It is working fine.


This thread is closed