16
Shakti Gohil Senior Application Engineer [email protected] Search

Ektron London Conference: New Search Features in Ektron 9

  • Upload
    ektron

  • View
    718

  • Download
    7

Embed Size (px)

Citation preview

Page 1: Ektron London Conference: New Search Features in Ektron 9

Shakti Gohil

Senior Application Engineer

[email protected]

Search

Page 2: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Agenda

• New search provider SOLR in Ektron9

• Building blocks of Search API

• Examples and Hands On

Page 3: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

SOLR

• Based on Apache Lucene

• Provides a robust enterprise search

functionality

• Includes faceted search,

recommendation of similar results, spell

check and more

• Ektron Search is now built on SOLR

Page 4: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

SOLR – what you need?

• Based on JAVA

• Java development kit (JDK)

• Server

• Glassfish, JBoss, Jetty, Resin, Tomcat, WebLogic,

WebSphere

• User account

• User must have “Log on as a Service” right from

local security policy

• SQL server: TCP/IP enabled

• SOLR Install

Page 5: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Building Blocks of Search API

• Search Manager

• Criteria

• Keyword Criteria

• Advanced Criteria

• SearchResponce

Page 6: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Criteria

• Keyword Criteria

• Free text, keyword centric search query

• Intended for broad, traditional search

query

• Advance Criteria

• Narrow search results using expression tree

• For narrower, targeted query

Page 7: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Example Code

• Simple search

• Spelling suggestion

• Expression Tree• Content Property

• Smartform Property

• Metadata Property

• Faceted search on• Smart form

• Metadata

• Taxonomy

Page 8: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Simple Search

// Create instance search manager

Ektron.Cms.Search.SearchManager searchManager = new

Ektron.Cms.Search.SearchManager();

// Create instance of keyword criteria

Ektron.Cms.Search.KeywordSearchCriteria criteria = new

Ektron.Cms.Search.KeywordSearchCriteria();

// Search for pain text

criteria.QueryText = "product";

// pass criteria object in search method to get search results

var searchResponce = searchManager.Search(criteria);

Page 9: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Spelling suggestion

// searchResponce object contains search results

var searchResponce = searchManager.Search(criteria);

// Check for spelling suggestion

if (!string.IsNullOrWhiteSpace(searchResponce.SpellingSuggestion))

{

// code to display spelling suggestion on page

// searchResponce.SpellingSuggestion – string stores suggested spelling

}

Page 10: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Expression Tree

// Create instance of advanced criteria

Ektron.Cms.Search.AdvancedSearchCriteria criteria = new

Ektron.Cms.Search.AdvancedSearchCriteria();

// Build expression tree – add search content property

criteria.ExpressionTree = SearchContentProperty.Id > 0 &

SearchContentProperty.XmlConfigId.EqualTo(7);

// Add smart form property - date

criteria.ExpressionTree &=

SearchSmartFormProperty.GetDateProperty("/root/pubDate").GreaterThan(new

DateTime(2013, 5, 25));

// Add metadata property

criteria.ExpressionTree &=

SearchMetadataProperty.GetStringProperty("Region").EqualTo(“Europe");

Page 11: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Faceted Search

• RefinementSpecification• Identifies a field on which facets should be

generated.

• Does not specify any additional constraints.

• Refinement• Identifies the facet field and a constraint that

should be applied to refine the query.

• This is applicable when the user has selected a specific facet value/range by which they intend to refine their query.

Page 12: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Faceted Search

// Add refinement specification - Fields on which facet should be generated

criteria.Refinement.Add(new

StringRefinementSpecification(SearchSmartFormProperty.GetStringProperty("/root

/author")));

criteria.Refinement.Add(new

StringRefinementSpecification(Ektron.Cms.Search.Solr.SearchSolrProperty.CreateE

xactStringProperty(SearchContentProperty.TaxonomyCategory)));

criteria.Refinement.Add(new

StringRefinementSpecification(SearchMetadataProperty.GetStringProperty("Regio

n")));

Page 13: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Faceted Search

// Add refinement specification - Fields on which facet should be generated

criteria.Refinement.Add(new StringRefinementSpecification(SearchSmartFormProperty.GetStringProperty("/root/author")));

// After SEARCH operation, Get facet information from SearchResponceData

var authorFacet = searchResponce.Facets[SearchSmartFormProperty.GetStringProperty("/root/author")];

foreach (UniqueFacetBucket<string> bucket in authorFacet.Buckets) {

if (bucket.Count > 0) {

// bucket.Refinement.Data – stored key:value pair

// bucket.Value – facet value

// bucket.Count – number of item fall in this bucket

}

}

Page 14: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Faceted Search

How to add refinement condition.

// Smart form refinement

criteria.Refinement.Add(new

Ektron.Cms.Search.Refinement(Ektron.Cms.Search.SearchSmartFormProperty.Get

StringProperty("/root/author"), " estrootauthor:jonathan"));

// Metadata refinement

criteria.Refinement.Add(new

Ektron.Cms.Search.Refinement(SearchMetadataProperty.GetStringProperty("Regi

on"), “emtregion:europe”))

//searchManager.search operation code

var searchResponce = searchManager.Search(criteria);

Page 15: Ektron London Conference: New Search Features in Ektron 9

Shakti Gohil

Senior Application Engineer

[email protected]

Questions ?

Page 16: Ektron London Conference: New Search Features in Ektron 9

Copyright © 2013 Ektron, Inc.

Thank You