1 / 16

Zoeken met Sitecore 7

Zoeken met Sitecore 7. Egbert Wietses. pionect.nl. Waar komen we vandaan?. http://marketplace.sitecore.net/en/Modules/Sitecore_Item_Buckets.aspx. Item buckets. Niet zichtbaar (standaard) Theoretisch ongelimiteerd aantal subitems Geen parent child relatie. Handig om te weten.

rollo
Download Presentation

Zoeken met Sitecore 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Zoeken met Sitecore 7 Egbert Wietses pionect.nl

  2. Waar komen we vandaan? • http://marketplace.sitecore.net/en/Modules/Sitecore_Item_Buckets.aspx

  3. Item buckets • Niet zichtbaar (standaard) • Theoretisch ongelimiteerd aantal subitems • Geen parent child relatie

  4. Handig om te weten • <setting name="BucketConfiguration.BucketFolderPath" value=„yyyy\/MM\/dd\/HH\/mm”/> • <field fieldName="group" storageType="YES" indexType="TOKENIZED"    vectorType="NO" boost="1f" type="System.GUID" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider”> • Luke = your friendhttps://code.google.com/p/luke/

  5. Zoeken • using (var context = ContentSearchManager.GetIndex(bucketItem as IIndexable).CreateSearchContext()) • { • var querySearch = context.GetQueryable<Models.Product>(); • querySearch = querySearch.Where(item => item._language.Equals("en")); • querySearch = querySearch.Where(item => item._templatename.Equals(MasterProductPage.TEMPLATE_NAME)); • querySearch = querySearch.Where(item => item.brand.Equals("TRUST")); • var products = querySearch.ToList(); • } • public class Product: SearchResultItem • { •         public string _group { get; set; } •         public string _name { get; set; } •         public string _language { get; set; } •         public string _templatename { get; set; } •         public string color { get; set; } •         public string device { get; set; } •         public string feature { get; set; } •         public string operatingSystem { get; set; } •         public string compatibility { get; set; } • }

  6. Facet Search

  7. Coveo

  8. Linq to Sitecore = gold • All • Any • Between — with an extra overload for including or excluding the start and end ranges. • Boost — makes this part of the query more important than the other parts. • Cast — you can use this instead of Select. • Contains • Count • ElementAt • EndsWith • Equal • Facets — an extension that fetches the facets of predicates. • First • FirstOrDefault • Last • LastOrDefault • Min • Max • Match — an extension for running regular expression queries. • OrderBy • OrderByDescending • Select • Single • SingleOrDefault • Skip • Reverse • Take • ToList() • ToLookUp() • ToDictionary() • Page — an extension that does Skip and Take automatically for you. • StartsWith • Union

  9. Facet implementatie • public static IQueryable<Facet> GetFacets(IQueryable<Product> query, string[] facets) •         { •             var facetGroups = new List<Facet>(); •             query = facets.Aggregate(query, (current, facetName) => current.FacetOn(c => c[facetName])); •             FacetResults facetResults = query.GetFacets(); •             foreach (FacetCategory category in facetResults.Categories) •             { •                 var group = new Facet(key, friendlyName); •                 foreach (Sitecore.ContentSearch.Linq.FacetValue facetValue in category.Values) •                 { •                     group.Values.Add(new Models.FacetValue(facetValue.Name, facetValue.Aggregate)); •                 } •                 facetGroups.Add(group); •             } •             return facetGroups.AsQueryable(); •         }

  10. Verschillende queries, verschillende taken

  11. 1 Call • using (var context = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext()) • { • var results = context.GetQueryable<Product>().Where(prod => prod.Content.Contains("search box text").FacetOn(f => f.Color).FacetOn(f => f.Gender)).GetResults(); • int totalHits = results.TotalHits; var searchResuls = results.Hits; var facets = results.Facets; • }

  12. namespace Sitecore.ContentSearch.Linq • { •     public static class QueryableExtensions •     { •         public static IQueryable<TSource> FacetOn<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector); •         public static IQueryable<TSource> FacetOn<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int minimumResultCount); •         public static IQueryable<TSource> FacetOn<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int minimumResultCount, IEnumerable<object> filterValues); •         public static IQueryable<TSource> FacetPivotOn<TSource>(this IQueryable<TSource> source, Expression<Func<FacetPivotQuery<TSource>, FacetPivotQuery<TSource>>> keySelector); •         public static IQueryable<TSource> FacetPivotOn<TSource>(this IQueryable<TSource> source, Expression<Func<FacetPivotQuery<TSource>, FacetPivotQuery<TSource>>> keySelector, int minimumResultCount); •         public static IQueryable<TSource> Filter<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate); •         public static FacetResults GetFacets<TSource>(this IQueryable<TSource> source); •         public static SearchResults<TSource> GetResults<TSource>(this IQueryable<TSource> source); •         public static SearchResults<TSource> GetResults<TSource>(this IQueryable<TSource> source, GetResultsOptions options); •         public static IQueryable<TSource> Page<TSource>(this IQueryable<TSource> source, int page, int pageSize); •     } • }

  13. Linq voorbeeld •  resultsQuery = resultsQuery.Where(item => •                     item.Path.StartsWith("/sitecore/content/sites/autohouse") •                     && !item.ExcludeFromSearchResults •                     && (item.TemplateName == ContentPage.TEMPLATE_NAME •                     || item.TemplateName == NewsDetailPage.TEMPLATE_NAME •                     || (item.TemplateName == MasterProductPage.TEMPLATE_NAME •                             && item.brand.Equals("Brand X") •                             && (item.useforsupport.Equals("1") || item.useforconsumerassortment.Equals("1"))) •                     || (item.TemplateName == ColorProductPage.TEMPLATE_NAME •                             && item.brand.Equals("Brand X") •                             && (item.useforsupport.Equals("1") || item.useforconsumerassortment.Equals("1"))) •                     ) •                     && item.Language.StartsWith(lang)).OrderByDescending(x => x.itemno);

  14. Predicate Builder = one to watch • OR AND XOR • Controleren tegen lijst van iD’s

  15. In de praktijk • Luke = your friend

  16. Achtergrond informatie • Sitecore 7 Autohaus projecthttps://github.com/Sitecore/autohaus • Developers guide to item buckets and searchhttps://sdn.sitecore.net/Reference/Sitecore%207/Developers%20Guide%20to%20Item%20Buckets%20and%20Search.aspx

More Related