Upload
ektron
View
718
Download
7
Embed Size (px)
Citation preview
Copyright © 2013 Ektron, Inc.
Agenda
• New search provider SOLR in Ektron9
• Building blocks of Search API
• Examples and Hands On
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
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
Copyright © 2013 Ektron, Inc.
Building Blocks of Search API
• Search Manager
• Criteria
• Keyword Criteria
• Advanced Criteria
• SearchResponce
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
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
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);
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
}
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");
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.
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")));
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
}
}
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);
Copyright © 2013 Ektron, Inc.
Thank You