Sitecore and Solr - and Solr.pdfآ  • Sitecore and Solr ... Sitecore/.NET developer by day and rookie

  • View
    0

  • Download
    0

Embed Size (px)

Text of Sitecore and Solr - and Solr.pdfآ  • Sitecore and Solr ... Sitecore/.NET developer by day...

  • Sitecore and Solr Ian Mariano and Steven Zhao

    NorthPoint Digital

  • Agenda • Who We Are • Solr Overview • Sitecore and Solr

    • Setup • Nuances • Use Cases and Demos

    • Scaling Solr • Q & A

  • Who We Are

  • NorthPoint

    • Based in NYC with offices in BOS and PHL • Agile solutions for Financial and Digital markets • Digital

    • Delivering scalable content solutions • Focus on business outcomes and solution platforms • Technology Agnostic • Open Source, Java/Mobile, .NET, Big Data practices

    We Lead with Experience

  • NorthPoint Some of Our Clients

  • NorthPoint Ian Mariano

    Steven Zhao

    Project Manager - Digital

    Senior Consultant - Digital

    20+ years operating in the intersection of technology and man Colleague of instigators, storytellers and purveyors of fine design

    Sitecore/.NET developer by day and rookie dad by night Sometimes it is the other way around

    @ianmariano - ian_mariano@northps.com

    @stevenzhaonps - steven_zhao@northps.com

    mailto:ian_mariano@northps.com mailto:steven_zhao@northps.com

  • Solr Overview • Open source search based on Apache Lucene

    • Extensible schema • Expanded query language • Faceted search and filtering • Extensible caching • Highly scalable and available • Index external data sources • Expanded update formats • Rich document processing • Multiple search collections

    http://lucene.apache.org/solr/

    http://lucene.apache.org/solr/

  • Sitecore and Solr

  • Sitecore Solr Setup

    • Setup Solr • Download and configure • Local / Jetty for development • Use Tomcat / Glassfish / other servlet container for production

    • Use dedicated servers (instances) • Think about security

    • Create an initial itembuckets collection for Sitecore native

  • Sitecore Solr Setup

    Solr Setup Demo

  • Sitecore Solr Setup

    • Setup Sitecore to Use Solr • Download the appropriate Solr support package from SDN • Generate and install your schema.xml into the itembuckets collection • Configure the Solr endpoint • If needed, choose your IOC container • Re-Index

  • Sitecore Solr Setup

  • Sitecore Solr Setup

    Sitecore Solr Configuration Demo

  • Sitecore Solr Nuances

    • Item buckets and content editor search • What about missing field(s) from query results? • What are dynamic fields? • What are computed fields?

  • Sitecore Solr Use Cases • General search

    • Faceting • Autocomplete • Boosting

    • Search external sites • File crawling • Big data / external data

  • Sitecore/Solr General Search • Searching can be across any specific field • If no fields are provided, then the 

default field is used (configurable) • General queries • Pagination • Sorting • Filtering • Return only specific fields

  • Sitecore/Solr General Search Querying! ! q=stent! ! SolrQueryResults r = solr.Query(new SolrQuery(“stent”)); ! q=title:stent AND summary:aorta! ! SolrQueryResults r = solr.Query( new SolrQueryByField(“title”, “stent”) && new SolrQueryByField(“summary”, “aorta”)); ! q=title:stent OR title:aorta! ! SolrQueryResults r = solr.Query( new SolrQueryByField(“title”, “stent”) || new SolrQueryByField(“summary”, “aorta”));

  • Sitecore/Solr General Search Pagination! ! start=x&rows=y (zero-based)! ! new QueryOptions { Start = x, Rows = y } ! Sorting! ! sort=field1 asc, field2 asc, …! ! queryOptions.AddOrder(new SortOrder(“field”, Order.ASC));

  • Sitecore/Solr General Search Filtering! ! fq=type:news&fq:category:us! ! queryOptions.FilterQueries = new ISolrQuery[] { new SolrQueryByField(“type”, “news”), new SolrQueryByField(“category”, “us”) }; ! fq=+type:news +category:us! ! queryOptions.FilterQueries = new ISolrQuery[] { new SolrQueryByField(“type”, “news”) && new SolrQueryByField(“category”, “us”) };

  • Sitecore/Solr General Search Returning Specific Fields! ! fl=id title summary! ! new QueryOptions { Filter = new[] { “id”, “title”, “summary” } } ! fl=* score! ! new QueryOptions { Filter = new [] { “*”, “score” }
}

  • Solr Faceted Search • Directed search like Amazon / Zappos • Have a faceting strategy in line with your content strategy • Facet by

    • Field value • Field range • Subqueries

  • Solr Faceted Search • Field value (content containing Lincoln faceting on categories and author counts)

    • q=lincoln • facet=true • facet.field=category • facet.field=author • facet.mincount=1 !

    ISolrOperations solr = 
 
ServiceLocator.Current.GetInstance(); 



SolrQueryResults results = solr.Query 

( 
 new SolrQuery("lincoln"), 
 
 new QueryOptions 

 { 
 Facet = new FacetParameters 

 { 
 Queries = new[] { new SolrFacetFieldQuery("category"), 

 new SolrFacetFieldQuery("author") }, 

 MinCount = 1 
 } 
 } 
);


  • Solr Faceted Search • Field range (matching products faceting on price ranging from 0 to 1000)

    • q=headphones • facet=true • facet.range=price • facet.range.start=0 • facet.range.end=1000 !

    ISolrOperations solr =
 
ServiceLocator.Current.GetInstance(); 



SolrQueryResults results = solr.Query 

( 
 new SolrQuery("headphones"), 
 
 new QueryOptions 

 { 
 Facet = new FacetParameters 

 { 
 Queries = new[] { 

 new SolrFacetQuery( new SolrQueryByRange("price", 0m, 1000m) )
 }, 

 MinCount = 1 
 } 
 } 
);


  • Solr Faceted Search • Subqueries (matching products faceting on specific price ranges)

    • q=headphones • facet=true • facet.query=price:[0 TO 99] • facet.query=price:[100 TO 199] • facet.query=price:[200 TO *] !

    ISolrOperations solr =
 
ServiceLocator.Current.GetInstance(); 



SolrQueryResults results = solr.Query 

( 
 new SolrQuery("headphones"), 
 
 new QueryOptions 

 { 
 Facet = new FacetParameters 

 { 
 Queries = new[] { 

 new SolrFacetQuery( new SolrQueryByRange("price", 0m, 99m) ), 

 new SolrFacetQuery( new SolrQueryByRange("price", 100m, 199m) ),

 new SolrFacetQuery( new SolrQueryByRange("price", "200", "*") ) 
 }, 

 MinCount = 1 
 } 
 } 
);

  • Solr Autocomplete

    • Via faceting or limited fields • Define a field type for autocompletion

    • Choose a tokenizer (whitespace) • Filter to lowercase to normalize queries • Filter using EdgeNGramFilterFactory to match word beginnings

  • Solr Autocomplete • Example: autocomplete list for a category facet

    • q=*:* • rows=0 • facet=true • facet.field=category • facet.mincount=1 • facet.limit=5 • facet.prefix=home !

    ISolrOperations solr =
 
ServiceLocator.Current.GetInstance(); 



SolrQueryResults results = solr.Query 

( 
 SolrQuery.All, 
 
 new QueryOptions 

 { 
 Facet = new FacetParameters 

 { 
 Queries = new[] { 

 new SolrFacetFieldQuery("category"), 
 
 }, 

 MinCount = 1, 

 Limit = 5, 

 Prefix = "home" 
 },

 Rows = 0 
 } 
);

  • Solr Autocomplete • Example: autocomplete list for a category field

    • q=category:*headph* • rows=0

    ISolrOperations