Gravatar for jgopikannan@gmail.com

Question by gopi, Jan 11, 2016 12:40 AM

Creating Custom Facets in sitecore

Hello,

I need to create custom facet in sitecore and i followed the below procedure.

  1. Created facets in sitecore (/sitecore/system/Settings/Buckets/Facets)
  2. Mapped the existing field in fieldname section in facet (fieldname='title')
  3. Indexing is done for the item

But i use this facet in below query .FacetOn(f => f["title"]).GetFacets();

Am not getting results ,so i checked in CES Admin Tool index browser in there the Facet is unchecked .

After i adding this in config file i able to use this in FacetOn .

<fieldType fieldName="title" includeForFreeTextSearch="true" isFacet="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />

Is there any other way to use this facet without adding in config file , because my requirement will create many facets so everytime adding in config file will be impossible.

kindly give me a solution to overcome this . Thanks in advance

Gravatar for vlambert@coveo.com

Comment by vince, Jan 11, 2016 3:44 PM

Normally, a field mapped to a Facet is automatically set as Facet in Coveo ( https://developers.coveo.com/display/SitecoreV3/Inserting+and+Customizing+a+Facet+Component ), no need to change the config. What version of Coveo for Sitecore are you using?

You also need to wait for the changes to be propagated to the Coveo server after modifying the Buckets > Facets. If you are using the .FacetOn() in the Web database, have you published the site?

Gravatar for jgopikannan@gmail.com

Comment by gopi, Jan 11, 2016 5:14 PM

In our project, we use Coveo Enterprise Search 7 in sitecore 7.5. We are using "sitecoremasterindex" database only, but after indexing when we see the field in the "index browser", we would see the isFacet unselected as default. It appears only when the above config entry is added. Please suggest us on what went wrong or anything else is missing.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Jan 11, 2016 9:50 PM

Hi,

I just tried the following procedure and it works as expected in Sitecore 8.0 Update-2 with the June 2015 release of Coveo for Sitecore:

  1. Added a "Call to Action Text" facet item in the /sitecore/system/Settings/Buckets/Facets/ folder.
  2. Defined the "Field Name" field of that facet item to be exactly "Call to Action Text" which is the exact name of a field in one of my templates.
  3. Rebuild my Coveo indexes from the Sitecore Indexing Manager.
  4. In Coveo Enterprise Search Administration Tool, the @fcallz32xtoz32xactionz32xtez120xtXXXXX field was set as "Facet" in the fields sets.

A few things to pay attention to:

  • The really important part when configuring facet fields from the facets bucket is to set their "Field Name" field very carefully. The value of this field must be a Sitecore template field name or a computed index field name. A leading or trailing space can cause your field not to be set as a facet in CES. The case might also be important. Better use the same case as the Sitecore template fields.
  • You need to re-index the Sitecore items containing a value for that field in order for CES to build its facet values data structure. Forgetting to re-index would lead to no facet items in your search results.
  • You need to wait until CES has committed the index transaction before running your queries. CES commits the transactions every few hundreds of documents processed or every minute, whichever comes first.

To further troubleshoot your problem, would you mind to give me the following:

  • Your Sitecore version (Major.minor and revision)
  • Your Coveo for Sitecore build (3.0.XXXX)
  • Your CES version (7.0.XXXX)

Thanks

Gravatar for jgopikannan@gmail.com

Comment by gopi, Jan 12, 2016 5:06 AM

I created a facet and configured existing field in facets bucket .The mapped field is a sitecore template field and double checked the fieldname used in facet which is exactly the same and also casing matches.

Find the version details of Sitecore and Coveo.

  • Sitecore version -7.5
  • Coveo for Sitecore 7.5 3.0 (1123)
  • CES version - 7.0
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Jan 12, 2016 4:20 PM

Can you give me:

  • The type of the Sitecore field you are trying to set as facet
  • The revision of Sitecore 7.5 you are using (Update-? or rev ??????)
  • The build number of CES 7.0 you are using (This can be found at the bottom of every page of the CES Administration tool website)

Thanks

Gravatar for jgopikannan@gmail.com

Comment by gopi, Jan 13, 2016 6:59 AM

Find the required details below. SitecoreField Type : We are using single-line-text and droplist (we had this issue even using single-line-text alone) Sitecore version :Sitecore.NET 7.5 (rev. 141003) CES Build number : 7.0 x64 Build 7914.0

Just to give more insight on this issue without adding it in config , in CES Admin Tool Fields only 'Field Queries' checkbox is selected for new facet.

Gravatar for jgopikannan@gmail.com

Comment by gopi, Jan 13, 2016 11:18 AM

Please find the below information.

Sitecore Field Type: Single-line-text and dropdownlist (even it didnt work when I had only single-line-text) Sitecore Version: Sitecore.NET 7.5 (rev. 141003) CES Admin Tool: 7.0 x64 Build 7914.0

Gravatar for jgopikannan@gmail.com

Comment by gopi, Jan 13, 2016 2:17 PM

Please find the exact problem which we have got.

We have created custom facets in sitecore (inside Facets) with the name of a field in an item (same name as in template). We added the facet to the same item which has that particular named field. When we index that item, we are not able to get that facetfieldname set to isFacet in FieldSet of the Administrative tool. Hence when we do Coveo Linq query to get results (GetResults) based on facets, the facet categories is always returned as 0. Is there any setting that I am missing to get that field in coveo administrator tool set to ‘Facet'?

Name: ftemplatename5541 Metadata Name: templatename Type: String Default Value: [EMPTY] Field Queries: [SELECTED] FreeText Queries: [UNSELECTED] Facet: [UNSELECTED] Multi-valueFacet: [UNSELECTED] Sort: [UNSELECTED] Display Field: [SELECTED]

I have understood that the facet categories are returned on Coveo Linq queries only if the Facet/Multi-value Facet is selected.

Instead of adding it to the config file everytime for every new custom, suggest me the way to get it automatically selected. Let me know if I am missing anything anywhere.

-Gopi

1 Reply
Gravatar for vlambert@coveo.com

Answer by vince, Jan 11, 2016 1:49 PM

Another way to specify the field to be Facet, outside of the config file, is to use the coveoBeforeUpdateFieldSetPipeline pipeline.

As stated in this page, https://developers.coveo.com/display/SitecoreV3/Understanding+the+Indexing+and+Search+Pipelines, you can use a processor to update the IsFacet flag on specific fields, before they get updated in CES:

FieldConfig fieldConfig = p_Fields.FirstOrDefault(
    field => String.Equals(field.SitecoreFieldName, "NumericField1")
);

if (fieldConfig != null) {
    fieldConfig.IsFacet = true;
}

It will be up to you to devise a way to identify the fields you need to set as Facets.

Gravatar for jgopikannan@gmail.com

Comment by gopi, Jan 11, 2016 2:32 PM

Thank you very much, for the other way suggested. But our scenario is like i will be adding multiple facets (more than 100s of facets) in sitecore end and it will be very complex to add in config or code every time while indexing facets.

Is there any way to get this implemented with common piece of code without adding any code or config everytime?

Thanks in advance.

Ask a question