How to Index guids in Coveo keeping the original format – Part 1

Recently I have been working on a Sitecore project in which I needed to index a sitecore item ID and keep it`s original guid format using Coveo. At indexing time Coveo by default parses all guids to a short guid format.

So for example this guid {FBC05E55-55CA-443C-A3BA-7AE5AA14E2CF} would be transformed to this value fbc05e5555ca443ca3ba7ae5aa14e2cf after indexed.

This is done because there is a converter associated with the type Sitecore.Data.ID(which is the type of the item ID) that will parse that specific type at indexing time from a guid to a short guid.

As I was looking for options I posted a question on Coveo’s answers forum and got the suggestion of creating a custon conversionType and a custom type to get that done.

Understanding conversionTypes

Conversion types are useful to map how Coveo Enterpresie Search handles each type encountered at indexing time(more on the conversion process here). Taking the example described above when Coveo is indexing, it will look for each type of the fields being indexed and convert that type using a converter associated with that type. Complicated right?

You can read it as the following: every time Coveo indexes a guid it will use the converter to make a guid become a short guid. The same goes for other types.

Ok but where is this mapping done? I’m glad you asked ūüôā

If you open your Coveo.SearchProvider.config file and look for the conversionTypes section you will notice that the type Sitecore.Data.ID is associated with the conversionType IndexFieldGuidValueConverter. This will make sure that guids become short guids at indexing time.

The conversion itself happens on the method CovertTo. The ConvertTo method for this class is defined like this:

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return ID.Parse((Guid)value).ToShortID().ToString().ToLowerInvariant();
}

On part 2 of this post I will explain how I to implement a custom converter and have a guid being indexed with its original format.

How to Index guids in Coveo keeping the original format – Part 2

Now that we know what conversion types are(see part 1) it’s time to implement a custom conversion type. Here are a few steps you can take to achieve that.

1- The first thing you need to do is create a new type and add a property ID of type Sitecore.Data.ID to it’s definition as implemented bellow:

public class CustomGuid
{
      public ID ID { get; set; }
      public CustomGuid(ID id)
      {
           ID = id;
      }
}

2- On the Coveo.SearchProvider.Custom.config file add a new computed field definition to the AddComputedIndexField section:

<field fieldName=”guidid” >MyNamespace.GuidID, MyProjectAssembly</field>

3- Now you need to create the corresponding type defined on step 2, which should implement IComputedIndexField:

public class GuidID : IComputedIndexField
{
      public string FieldName { get; set; }
      public string ReturnType { get; set; }
      public object ComputeFieldValue(IIndexable indexable)
      {
            Precondition.NotNull(indexable, () => () => indexable);
            IItem item = new ItemWrapper(new IndexableWrapper(indexable));
            return new CustomGuid(item.ID);
      }
}

Note that the return of the ComputeFieldValue method is a new instance of CustomGuid(defined on step 1) passing the item ID to the constructor. This is really important since the mapping is done on the type CustomGuid.

4- We need to implement now a custom type converter. This class should inherit from System.ComponentModel.TypeConverter

public class CustomGuidConverter : TypeConverter
{
      public CustomGuidConverter()
      {}
      public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
      {
            if (destinationType == typeof(string))
            {
                  return true;
            }
            return base.CanConvertTo(context, destinationType);
      }
 
      public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
      {
            return ((CustomGuid)value).ID.ToString();
      }
}

Note the method ConvertTo and its parameters. The parameter value type is CustomGuid defined on step 1 so we know we can cast to it. Also we know we stored the Sitecore item’s ID on the property ID so we can essentialy return it as as string.

5- On the Coveo.searchprovider.custom.config we need to map the custom converter with the type we defined on step 1. Look for the section indexFieldStorageValueFormatter and add the following patch definition:

<indexFieldStorageValueFormatter type="Coveo.SearchProvider.CoveoIndexFieldStorageValueFormatter, Coveo.SearchProvider" >
     <conversionTypes hint="raw:AddConverter">
          <!--Converts Short guid format to guid regular format-->
          <conversionType inputType="MyNamespace.CustomGuid" type="MyNamespace.CustomGuidConverter, MyAssembly"
patch:before = "*[1]" />
     </conversionTypes>
</indexFieldStorageValueFormatter>

With this configuration Coveo will read at indexing time what the mapping should be.

  1. On Sitecore’s control panel rebuild your Coveo indexes.
  2. That’s it. After indexing if you open a document indexed you should look for the guidid field and you will see the guid indexed with its original value.

How to Index guids in Coveo keeping the original format – Part 1

Recently I have been working on a Sitecore project in which I needed to index a sitecore item ID and keep it`s original guid format using Coveo. At indexing time Coveo by default parses all guids to a short guid format.

So for example this guid {FBC05E55-55CA-443C-A3BA-7AE5AA14E2CF} would be transformed to this value fbc05e5555ca443ca3ba7ae5aa14e2cf after indexed.

This is done because there is a converter associated with the type Sitecore.Data.ID(which is the type of the item ID) that will parse that specific type at indexing time from a guid to a short guid.

As I was looking for options I posted a question on Coveo`s answers forum and got the suggestion of creating a custon conversionType and a custom type to get that done.

 

Understanding conversionTypes

Conversion types are useful to map how Coveo Enterpresie Search handles each type encountered at indexing time(more on the conversion process here). Taking the example described above when Coveo is indexing, it will look for each type of the fields being indexed and convert that type using a converter associated with that type. Complicated right?

You can read it as the following: every time Coveo indexes a guid it will use the converter to make a guid become a short guid. The same goes for other types.

Ok but where is this mapping done? I’m glad you asked ūüôā

If you open your Coveo.SearchProvider.config file and look for the conversionTypes section you will notice that the type Sitecore.Data.ID is associated with the conversionType IndexFieldGuidValueConverter. This will make sure that guids become short guids at indexing time.

The conversion itself happens on the method CovertTo. The ConvertTo method for this class is defined like this:

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
       return ID.Parse((Guid)value).ToShortID().ToString().ToLowerInvariant();
}

On part 2 of this post I will explain how I to implement a custom converter and have a guid being indexed with it’s original format.

Click here to see the part 2 of the post

Como indexar guids utilizando Coveo e Sitecore mantendo o formato original – Parte 2

Agora que sabemos o que conversiontype é(ver parte 1 deste post), esta na hora de implementar um conversiontype. Seguem 6 passos para implementá-lo.

1- A primeira coisa que você precisa fazer é criar um novo tipo, e adicionar a propriedade ID do tipo Sitecore.Data.ID conforme abaixo:

public class CustomGuid
{
      public ID ID { get; set; }

      public CustomGuid(ID id)
      {
           ID = id;
      }
}

2- No arquivo Coveo.SearchProvider.Custom.config adicione um novo computed field na seção AddComputedIndexField:

<field fieldName=”guidid” >MyNamespace.GuidID, MyProjectAssembly</field>

3- Agora você precisa criar o tipo correspondente definido no passo 2, que deve implementar a interface IComputedIndexField:

public class GuidID : IComputedIndexField
{

      public string FieldName { get; set; }

      public string ReturnType { get; set; }

      public object ComputeFieldValue(IIndexable indexable)
      {
            Precondition.NotNull(indexable, () => () => indexable);

            IItem item = new ItemWrapper(new IndexableWrapper(indexable));

            return new CustomGuid(item.ID);
      }
}

Repare que o tipo de retorno é uma instancia de CustomGuid(definido no passo 1), passando o ID do item para o construtor.

4- Agora precisamos implementar o conversor. Esta classe deve herdar de System.ComponentModel.TypeConverter

public class CustomGuidConverter : TypeConverter
{
       public CustomGuidConverter()
       { }

       public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
       {
             if (destinationType == typeof(string))
             {
                   return true;
             }
             return base.CanConvertTo(context, destinationType);

       }

       public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)

       {

             return ((CustomGuid)value).ID.ToString();

       }
}

Repare o m√©todo ConvertTo e seus par√Ęmetros. O tipo do parametro value √© CustomGuid definido no passo 1, ent√£o sabemos que podemos fazer o cast para este tipo. Ainda, sabemos que na propriedade ID foi armazenado o ID do item de Sitecore, ent√£o √© poss√≠vel retornar o valor do ID como uma string.

5- No arquivo Coveo.Searchprovider.custom.config, precisamos realizar o mapeamento do conversor com o tipo definido no passo 1. Procure a seção indexFieldStorageValueFormatter e adicione o seguinte:

<indexFieldStorageValueFormatter type="Coveo.SearchProvider.CoveoIndexFieldStorageValueFormatter, Coveo.SearchProvider" >

       <conversionTypes hint="raw:AddConverter">

              <!--Converts Short guid format to guid regular format-->

              <conversionType inputType="MyNamespace.CustomGuid" type="MyNamespace.CustomGuidConverter, MyAssembly" patch:before = "*[1]" />

      </conversionTypes>

</indexFieldStorageValueFormatter>

Com esta configuração o Coveo vai realizar o mapeamento em tempo de indexação.

6- No painel de controle do Sitecore faça o build dos indices do Coveo.

7- Feito! Após a indexação, se você abrir o documento indexado você deverá procurar pelo field  guidid e você verá que o guid foi indexado com o seu valor original.

Como indexar guids utilizando Coveo e Sitecore mantendo o formato original – Parte 1

Recentemente eu trabalhei em um projeto de Sitecore, no qual eu necessitava indexar o ID de um item de Sitecore e manter o formato de guid original utilizando Coveo. Em tempo de indexação, o Coveo altera o formato das guids para o formato short guid.

Por exemplo, esta guid {FBC05E55-55CA-443C-A3BA-7AE5AA14E2CF} seria transformada neste valor fbc05e5555ca443ca3ba7ae5aa14e2cf, após indexado.

Isso √© feito porque existe um conversor associado com o tipo Sitecore.Data.ID(que √© o tipo correspondente do ID dos itens de Sitecore), respons√°vel por transformar o tipo spec√≠fico em tempo de indexa√ß√£o do formato guid para short guid. Enquanto eu procurava op√ß√Ķes, eu postei uma pergunta no forum da Coveo¬† e me foi sugerido criar um conversor(ConversionType) e um tipo espec√≠fico para resolver este problema.

Entendendo ConversionTypes

ConversionTypes são uteis para mapear como o Coveo Enterprise Search manipula cada tipo encontrado em tempo de indexação(maiores detalhes do processo de conversão aqui). Utilizando o exemplo descrito acima, quando o Coveo está indexando, para cada tipo dos campos diferentes de Sitecore(fields) será feito um mapeamento entre o tipo indexado e o conversionType correspondente. Complicado?

Pense assim: Toda vez que o Coveo indexar uma guid ele vai usar o conversor para fazer a guid ser indexada como short guid. O mesmo ocorre para outros tipos.

Certo, mas onde o mapeamento √© feito? Que bom que voc√™ perguntou ūüôā

Se voce abrir o arquivo Coveo.SearchProvider.config e procurar a seção ConversionType, voce verá que o tipo Sitecore.Data.ID está associado com o conversionType IndexFieldGuidValueConverter. Isso garantirá que as guids sejam indexadas como short guids em tempo de indexação.

A conversão em si acontece no método ConvertTo. O método ConvertTo para esta classe é definido da seguinte forma:

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
     return ID.Parse((Guid)value).ToShortID().ToString().ToLowerInvariant();
}

Na parte 2 deste post, eu explicarei como eu implementei um conversor customizado, fazendo com que o tipo guid, ao ser indexado mantivesse o seu formato original.

Clique aqui pra ver a parte 2

Looking for how to create media type filters with Coveo for Sitecore? Here are 5 steps you can take to achieve it

One requirement that I have seen when implementing search pages with Coveo is to add filters to the search results based media type, i.e. show only pdf files, or docx files, etc. To do that you need to work with facets. Here are 5 steps you can take to add a facet filter to your search results page. You can also¬†reffer to¬†Coveo’s documentation¬†on how to add facets to search pages here.

  1. Make sure there is content in the media library. If you don’t have just upload a few docx documents, images and pdfs as in this example

1

2. Rebuild the Coveo indexes.

3. Using the Experience Editor open the Coveo search results page

4. On the left hand side click the “Add here” button and add a Coveo Facet View component than click Ok.

2

5.¬†A pop-up will show to configure the properties of the facet component. Add a title on the field “Title” and on the field “Field” select from the dropdown “File Type” and click ok.

3

That’s it. Now you can interact with the facet component and filter the content of the search results page based on media type:

4

 

Procurando como criar filtros a partir de tipos de arquivos com Coveo para Sitecore? Seguem 5 passos para implementar isto

Um requisito que uma vez vi, enquanto estava implementando páginas de busca com Coveo, foi o de adicionar filtros para as páginas de busca a partir de tipos de arquivos, por exemplo, mostrar apenas documentos pdf, ou docx, etc. Para resolver isso você precisar implementar uma facet. Seguem 5 passos para adicionar a facet para a sua página de pesquisa, conforme sugerido na documentação da Coveo.

  1. Crie alguns exemplos de conte√ļdo na media library do Sitecore. Se voc√™ n√£o tiver, fa√ßa o upload de alguns documentos docx, imagens ou pdfs, conforme o exemplo abaixo:

1

2. Faça o rebuild dos índices do Coveo.

3. Usando o Experience Editor, abra a página de pesquisa do Coveo.

4.¬†Na coluna da esquerda, clique no bot√£o “Add here” e adicione um componente “Coveo Facet View” e depois clique OK.

2

5.¬†Um pop-up vai abrir para configurar as propriedades do componente. Adicione um valor para o campo “Title”. No campo “Field” selecione o valor “File Type” e depois clique OK.

3

Pronto! Agora voc√™ consegue filtrar o conte√ļdo da p√°gina de pesquisa a partir de tipos de dados:

4

 

Having issue starting the Coveo Search API service? This post might be useful

Are you installing Coveo and the Coveo Search API will not start? I had this problem and here is how I solved it.

THE PROBLEM

I have a Sitecore instance running locally and I was installing Coveo on premises for the first time locally. I had already installed all Coveo services and had updated the server section of my config.yml file to look like this:

Server:

uri: https://localhost:52810

serverCertificatePath: C:\CES7\Config\Certificates\cert-ca.pem

clientCertificatePath: C:\CES7\Config\Certificates\cert-iis.p12

But since I had not created the index just yet and this caused the service to not start properly. The error message I would get was “Windows could not start the Coveo Search API service on Local Computer”. Error 1067: The process terminated unexpectedly.

1

The same message would be captured on the Event Viewer so I thought that the next step would be to create the index.

THE SOLUTION
Here are 4 steps to fix this:

1- Open the Coveo Admin Tool(in my case http://localhost:8081) and I would get the Create Index form:

2

2- Open the Coveo Admin Tool(in my case http://localhost:8081) and I would get the Create Index form:

3

3- After pasting the license on the License field and clicking Apply Changes the Admin Tool Dashboard showed:

4.png

4- Now all I had to do was start the Coveo Search API service again and it would not stop:

5

After that I confirmed that Coveo for Sitecore was properly configured. To do that just access Sitecore’s control panel and look for Coveo’s Diagnostics Page:

6.png

Click here to see this post in portuguese

Instalando Coveo para Sitecore e o servi√ßo Coveo Search API n√£o inicia corretamente? Este post pode ser √ļtil!

Você está instalando Coveo e o serviço Coveo Search API não inicia corretamente? Eu tive este problema e abaixo descrevo como foi  o resolvi.
O PROBLEMA
Eu tenho uma inst√Ęncia de Sitecore rodando local e instalei o Coveo neste ambiente pela primeira vez. Eu j√° havia instalado o Coveo Enterprise Search e o Coveo Search API. Ap√≥s fazer isso eu atualizei a se√ß√£o server do meu arquivo de configura√ß√£o do Search API(config.yml) da seguinte forma:
server:
  uri: https://localhost:52810
  serverCertificatePath: C:\CES7\Config\Certificates\cert-ca.pem
  clientCertificatePath: C:\CES7\Config\Certificates\cert-iis.p12
Mas at√© ent√£o, eu ainda n√£o havia criado o √≠ndice o que fazia com que o servi√ßo n√£o iniciasse corretamente. A Mensagem de erro que eu recebia era “Windows could not start the Coveo Search API service on Local Computer. Error 1067: The process terminated unexpectedly.”
1
Essa mesma mensagem estava sendo mostrada no Visualizador de Eventos do Windows então pensei que o próximo passo seria criar o índice.
A SOLUÇÃO
Seguem 4 passos para resolver este problema.
1- Abre a ferramenta de administração do Coveo(no meu caso rodando no endereço http://localhost:8081) e a tela de criar o índice apareceu:2
2- Depois de definir os caminhos de configura√ß√Ķes, eu cliquei em Create Index e me foi solicitada a licen√ßa:
3
3- Após inserir a licença no campo e clicar em Apply Changes a tela de administração do Coveo apareceu:
4.png
4- Pronto! Agora a √ļnica coisa restante era iniciar o servi√ßo Coveo Search API:
5
Após isso eu confirmei que o Coveo e o Sitecore estavam devidamente configurados. Para verificar isso, acesse o Sitecore e vá no Painel de Controle e procure pela página de diagnosticos do Coveo. Todos os estados devem estar verdes e rodando:

6.png

Clique aqui para ver o post em inglês