zoeken met sitecore 7 egbert wietses pionect.nl. waar komen we vandaan? _buckets.aspx
TRANSCRIPT
![Page 2: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/2.jpg)
Waar komen we vandaan?
http://marketplace.sitecore.net/en/Modules/Sitecore_Item_Buckets.aspx
![Page 3: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/3.jpg)
Item buckets
• Niet zichtbaar (standaard)
• Theoretisch ongelimiteerd aantal subitems
• Geen parent child relatie
![Page 4: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/4.jpg)
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/
![Page 5: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/5.jpg)
Zoekenusing (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; }}
![Page 6: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/6.jpg)
Facet SearchFacet Search
![Page 7: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/7.jpg)
Coveo
![Page 8: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/8.jpg)
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
![Page 9: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/9.jpg)
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(); }
![Page 10: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/10.jpg)
Verschillende queries, verschillende taken
![Page 11: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/11.jpg)
1 Callusing (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;
}
![Page 12: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/12.jpg)
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); }}
![Page 13: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/13.jpg)
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);
![Page 14: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/14.jpg)
Predicate Builder = one to watch
• OR AND XOR
• Controleren tegen lijst van iD’s
![Page 15: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/15.jpg)
In de praktijkLuke = your friend
![Page 16: Zoeken met Sitecore 7 Egbert Wietses pionect.nl. Waar komen we vandaan? _Buckets.aspx](https://reader035.vdocuments.pub/reader035/viewer/2022062307/551b1e815503465e7d8b6715/html5/thumbnails/16.jpg)
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