Wednesday, December 28, 2016

Say Hello to Glass!!!!

Wanted to share something cool and powerful.  Not sure if you all are already aware, but, pretty awesome, so wanted to share regardless.


Goal – “To get descendants under an item in the content tree that are of specific template ID “

Many straight forward ways to achieve this. Like loading a VM on controller or a new property by casting and doing bunch of queries.
We are close to a launch and typically at this time, more code would mean more bugs and additional effort to resolve those.  I wanted to avoid this as much as possible. 

So, I tried loading what I needed through Glass like below.   That is it, Just two lines of code and everything loaded as I wished for. J
No casting, no object massaging, nothing at all.   So cool and yet so powerful.  It could come in handy for you all when working with hierarchical data.

 [SitecoreQuery(".//*[@@templateid='{A5617868-1226-4C7F-89A7-C7355BD1532A}']", IsRelative = true)]
       public virtual IEnumerable<MyTemplate> itemsOfMyTemplateUnderCurrent { get; set; }

Glass documentation helped me get a clue, but, it was more about children only and also note for some reason the sample format given by Glass did not work in case of descendants atleast. 
Notice the {} around GUID of template, my second try and wohoo!!! everything loaded in the object as I needed and wished for. 

Helpful reference:



Wednesday, December 14, 2016

Make Coveo For Sitecore work on Authenticated Sitecore URL

You have your Sitecore Instance URL protected.  Why? Many organizations do this to protect their under development site to be indexed or even worse seen by search engines and obviously you dont want any one who knows the URL to actually access your not so ready site or worse add a reference link or something.
So, yes, it is very common to have this kind of set up on lower environments while development is in progress.  It could be to share this URL with selected Clients for UAT or content load in some cases.
You have Coveo for Sitecore installed on this Sitecore instance that you protected using IIS authentication.
The Problem - "Coveo For Sitecore will not work - Diagnostics will fail 401, Index rebuilding will not work(401 again!) and obviously your renderings will not load as Indexes are not built yet"
Solution - While scrambling for a good solution and still leave the Sitecore Instance URL protected, we actually did find more than one solution through various unrelated sources and one from Coveo team as well . :)

Hopefully, this will help some one who is still scrambling and unable to find a solution.  Select which way to implement and go with based on your usage of Coveo Indexes.


  1. If your project uses plain old Coveo renderings and not use Coveo Indexes from Sitecore content search - You can choose to add another IIS site on CD server and point that to the same site, use this URL(internally open and no auth) to manage your coveo indexes. 
  2. If your project accesses Coveo indexes from code and content search - #1 wont work and will cause 500(Coveo rest end point to pull index will error due to 401 again). In this case, you have two options 
    • Disable IIS basic auth and use IP whitelisting for security instead as our infrastructure thinks this is a possible
    •  Keep IIS Authentication enabled on all folders of the Sitecore instance except Website\Coveo\rest and Website/Sitecore Modules/Web/Coveo 
Have fun Sitecoring and Coveofying your search. (New word..lol)






Saturday, November 19, 2016

New Items not Indexed on Coveo

New Items Not Showing Up on Coveo Indexes


You have set up everything alright.  All Coveo components are green, your search renderings show up fine on UI.  All is set! You are a rock star. 

You notice something really wierd, updates on sitecore content items show up fine on Coveo Indexes, but, new items added are not showing up on Indexes until you manually rebuild them using Indexing manager. Well, this is a problem we can not live with as we can not ask Content authors to actually rebuild indexes everytime they add a new item.  Bad solution!

Have to resolve this for sure, there is no option. 

Below are the check points I made - 
1. Check the logs for errors
2. Ensure on showconfig.aspx, Coveo index sync strategies are set up fine OOTB one's are perfect in most cases. 
3. Check CES console for any errors
4.  No luck so far, everything looks perfect. 
5. Next resort was CES Admin Tool, I  used localhost:8081 as I was debugging on my local. 
6. Dates looked pretty off and outdated, so, I tried to turn off and turn on Live Monitoring
7. Re-opened CES console and added new item
8. Voila!!! new items now showed up on Master 
9. Published and yep showed up on Live site too. 


Problem Solved!!!!  Back to being relaxed. :)
I posted this on Coveo Questions and Answers too so some one else in my shoes can probably benefit. 


Thursday, November 17, 2016

Coveo Facet Slider Across Two Fields

Coveo Facet Slider Across Two Fields


We had a requirement that obviously could not be achieved using OOTB Facet Slider control. 
We were aware of that and did know we need to do some customization.  Just did not realize that there wont be any to none straight forward solution. 
I came up with the below solution though was not heavily confident while re-iterating this to the team, just  felt worth a shot. 

Good news is after a lot gymnastics it did work. 

Goal -  Use Coveo Facet Slider on two fields on the same item.
Challenge - Coveo does not allow number based Multi Value Field on their Index, hidden challenge I can not base Facet Slider on a Multi Value String field either.  So, I am at wall in both directions. 

Solution - Fluke at first and reality the next 
Below are the steps I did
1. Turn off Auto Max/Min Calculation on Coveo facet slider on the layout
              We can have some livable manual entries for Max/Min on layout as they are required if not auto-generated, I will see what I can do here.
2.       Next, grab Max/Min across all Neighborhood’s under the current metro page from back end
3.       I overwrite the max/min of Coveo controls with this back end loaded Max/Min patching on to their exposed events.
4.       Now, the filtering by default could be based on only one field(our challenge) –“In our case Maximum Neighborhood Price”
5    I will have to hijack the rest api call that Coveo makes on slider change to inject this expression along with others it does, so I do not interrupt the inner workings of Slider.  Additional Detail: Used Disjunction available from Coveo query builder expressions  


 

Saturday, November 5, 2016

Coveo facets error

Coveo Facets Error 


So, you are on September release of coveo components and you do not have tab component on your search view.  You now want to add coveo facet or the view, which was added fine, but the facet though indexed and pointing to correct field, it would either not render fine on view, what would you do ??? 
I tried doing the below...
  • Checked conside and tried to debug error 
    •  Actual Error - 'Value can not be null or empty ' 
  • What value is coveo asserting for ?checked call stack,  nothing important is missing 
  • Checked Presentation Details and ensured that everything is set correctly. 
  • Dropped facet component , no error any more ...??
  • Slack conversation with Coveo team , no break through!!!! They asked to check if I am not hard coding 'Model .ID' like plain text, but, nope we were doing things the correct way. 


What else ??? Google should have been my first resort, but I like to do basic checks first, seems like I should follow the reverse order. 
Found below link and seemed very much related, so gave it a shot.  That's it!!!
It started working. Yippeeee!


Hope, this would help some one battling this issue and unaware that it is a known issue on September release. 

Few Screen Shots of Error for reference 


Sunday, October 16, 2016

Sitecore Tagging Surprises


Sitecore tagging is immensely powerful out of the box starting Sitecore 7+.  You can tag any items( including bucketed items)
The below links will get you started on the basic features -

https://visionsincode.wordpress.com/2014/11/16/tagging-is-fun-in-sitecore/

https://community.sitecore.net/technical_blogs/b/sitecore_7_development_team/posts/content-tagging-with-sitecore-7

https://doc.sitecore.net/sitecore_experience_platform/content_authoring/managing_items/general/add_a_tag_to_an_item

Now, coming to the surprises...


  1. While working with the basics,  the __Semantics field on my local sitecore instance did not look anything like the articles explain.  After some pondering,  it turns out my 'raw' view was checked.  So, for the multi-value search field to behave and allow selection as expected make sure this is unchecked.
  2. After adding some new tags into tag repository(),  when i go back to tagging section of my item, I did not see the newly added tags in the selection list.   This is because tagging depends and reads from indexes.  when i re-built my indexes, I could then see the new one's
  3. Since, tagging is so dependent on indexing,  selecting a good indexing strategy is very important.  Doing this operation only as often as needed and not overdoing goes long way.
To tackle #3,  it would be handy to know the default indexing strategies on master and web databases.  For master, the default is syncMaster and for web database, the default strategy is onPublishEndAsync.   You can apply different one's as needed, but, in our case the defaults would just do it. 

You can read more on indexing strategies available through Sitecore OOTB on the below article, Good reads. :)


https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/search_and_indexing/indexing/index_update_strategies

https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/sitecore-7-index-update-strategies

https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/search_and_indexing/indexing/rebuild_search_indexes

Thursday, October 13, 2016

Sitecore URL Duplication

Sitecore is amazing when it comes to how it can resolve a URL seamlessly to an item and how we can tune that based on requirements and project demands.
In most of the blogs out there - Good reads
https://jammykam.wordpress.com/2015/07/13/seo-friendly-urls-in-sitecore-prevention-is-better-than-cure/  - My Fav
http://reinoudvandalen.nl/blog/using-replacement-characters-in-sitecore-the-right-way/
https://www.cmsbestpractices.com/add-seo-value-by-replacing-spaces-with-dashes-in-sitecore/

you will see how you can tackle LinkManager using  to ensure you always have a good SEO friendly URL using <encodeNameReplacements> and how to avoid the side effects of this by ensuring we do not allow hyphen in item names using "InvalidItemNameChars"

Now, there are other problems we will have to deal with.  Google does not like duplicate content, which means when two URL's yield same result, in our case render same item content.  It means it is duplication.

But, though spaces are replaced by hyphens internally, it does not do anything when user or say some refferal link some where actually has spaces
For example - www.domain.com/test%20page and www.domain.com/test%20page would yield same page/content

Not Good...Google would not like it!

So, good SEO options are either do a 404 on space version(%20) above or do a 301 re-direct.  Canononical links might help a little if you cant do both of the above.

You could also you IIS re-write rules to replace spaces with '-' instead of %20

Wait for more...