Show the number of Coveo results in facets within brackets

Last Thursday evening out of the blue, the client asked to see the result count inside of brackets. It is a very intuitive feature that gives the searcher an indication of the big picture when searching and filtering.

The PROBLEM:


The ASK:

We were using the Coveo Atomic component, but there was no reason to not show the results inside brackets as it was the default behavior anywhere else. After much debugging, there was no indication of why the numbers were not within brackets but the client wants what the client wants. so, we took a short and simple way of implementing it using CSS.

.coveo {
  .coveo-facet-value-count:before, .coveo-facet-value-count:before {
    content: "(";
  }
}

This solved all our problems and the client lived happily ever after.

~ Unless you are easily worried about everything, try not to stress. ~

How to check if COVEO is active in your instance…

  1. got to https://<your-sitecore-url>/coveo/rest and see if you get JSON back. If you don’t you know what’s not there.
  2. Use the following code. But, Coveo dlls need to be there. if they dont we will get an (duh!) error but try catch could help you out here.
    var activator = new Coveo.Service.Api.ConfigServiceBase.Activators.InstanceActivator();    
    model.IsCoveoActivated = activator.IsActivated();

3. simple is king. Check if a config file exists.     
model.IsCoveoActivated = 
System.IO.File.Exists("C:\\inetpub\\wwwroot\\App_Config\\Include\\Coveo\\Coveo.SearchProvider.Custom.config");

AND BOOM!

~ Hope is a dangerous emotion. ~

Coveo Search – Item Result Template

Could not find much info on the innerwebs, so I thought I keep my notes on here.

I am using Coveo for Sitecore. WITH SXA.

File result templates are easier in my opinion but you have to change files and deploy to make any changes.

That’s why I decided to start using Item Result Template. You can just copy paste the script into the Sitecore item and BOOM! Wondering what you should use? underscore or server side? both works…

<div style="padding: 5px; ">
    <div class="my-result-template-header" style="display: flex; align-items: center;">
      <div class="CoveoIcon" data-small="true"></div>
      <div class="CoveoResultLink" data-field="{{= coveoFieldName("@title") }}" 
        style="flex-grow: 1; margin-left: 5px;"></div>
    </div>
      <div style="flex-grow: 1; margin-left: 5px;">
Template: <%= raw.z95xtemplatename %>
    </div>
    <div class="my-result-template-content">
      <div class="CoveoExcerpt"></div>
    </div>
    <div class="coveo-result-cell coveoforsitecore-time-cell">
        <% if (coveoFieldValue("created") === coveoFieldValue("updated")) { %>
        <div title='<%= translateLabel("Creation On") %>'>Created: <%- dateTime(raw.date) %></div>
        <% } else { %>
        <div title='<%= translateLabel("Last Modified") %>'>Modified: <%- dateTime(raw.date) %></div>
        <% } %>
    </div>
  </div>

This is just a start. Things will start to look better as you start adding more values and logic to this.

! Stay Home, Stay alive and keep learning !

Coveo supported python libraries to be used in Indexing Pipeline Extensions…

I love Coveo.

And looking forward to easier implementation and development. I am also looking to get a certification on that but it doesn’t seem like there is an easy option for that. Dear Coveo people, please take note.

Anyways, Coveo has these pre and post-processing scripts that you can set up to manipulate the data coming in and out very easily using python.

Image result for coveo pipeline extensions

Currently following are the libraries you can import and use in your scripts to do fun and complicated things.

  • Click, version 7.0
  • Flask, version 1.0.3′
  • Jinja2, version 2.10.1
  • MarkupSafe, version 1.1.1
  • Werkzeug, version 0.16.0
  • asn1crypto, version 1.0.0
  • beautifulsoup4, version 4.6.0
  • boto3, version 1.9.0
  • botocore, version 1.12.242
  • certifi, version 2019.9.11
  • cffi, version 1.12.3
  • chardet, version 3.0.4
  • cryptography, version 2.7
  • docutils, version 0.15.2
  • idna, version 2.8
  • itsdangerous, version 1.1.0
  • jmespath, version 0.9.4
  • ndg-httpsclient, version 0.4.2
  • pip, version 19.2.3
  • pyOpenSSL, version 19.0.0
  • pyasn1, version 0.2.3
  • pycparser, version 2.19
  • pycurl, version 7.43.0
  • pygobject, version 3.20.0
  • pyrapidjson, version 0.5.1
  • python-apt, version 1.1.0b1+ubuntu0.16.4.5
  • python-dateutil, version 2.8.0
  • requests, version 2.22.0
  • s3transfer, version 0.1.13
  • setuptools, version 20.7.0
  • six, version 1.12.0
  • uWSGI, version 2.0.17
  • unattended-upgrades, version 0.1
  • urllib3, version 1.25.6
  • wheel, version 0.29.0′

 

Enjoy and Use them wisely like everything else in life…

 

~ Try to know what shoes your colleagues are wearing at work, so you can tell who is in the toilet stall beside you. ~

Custom fields on Coveo Search result templates with conditions

Do you run Sitecore?

Do you have Coveo for searching the sites?

You are getting results back but now you want to add one of your fields in the result. This post is for you.

    • I have a meta_description field.
    • this is mapped to the description field from meta.
    • Once these are indexed I wanted these to show up on my search results.
    • If I didn’t have a description set then I would use Coveo’s auto-generated excerpts to show on the search result.
    • below is what I did:
    • <div class="coveo-result-cell">
          <% if(raw.meta_description){ %>
          <span class="description">
              {{= raw.meta_description}}<br />
          </span>
          <% } else { %>
              <span class="CoveoExcerpt description"></span>
          <% } %>
      </div>
      
      
    • And I had to add one more trick on js to get this field returned with the raw data from Coveo Cloud.
    •     Coveo.$$(searchRoot).on('buildingQuery',
              function (e, args) {
                  args.queryBuilder.addFieldsToInclude([
                      "meta_description"
                  ]);
              });
    • That’s it.

 

 

 

~ Don’t fall asleep when you are awake. ~

 

CS0104: ‘License’ is an ambiguous reference between ‘Coveo.CES.Web.Search.License’ and ‘Sitecore.SecurityModel.License.License’

Just my bad luck.

Had an old version of Coveo running on Sitecore 9. Both had License class and the Sitecore login page uses License.Licensee on the show License info panel.

Find Website\Sitecore\login\default.aspx

on line 164 (if you don’t have any other changes) change the following

<ul>
<li>System information</li>
<li>License holder <%# Sitecore.SecurityModel.License.License.Licensee %></li>
<li>License ID <%# Sitecore.SecurityModel.License.License.LicenseID %></li>
<li>Sitecore version <%# About.VersionInformation() %></li>
</ul>

Login page should start showing the login page 🙂

~ Socks are gloves and vice versa. ~