Gravatar for micallahan@logmein.com

Question by mcallahan, May 20, 2015 12:05 PM

Setting up indexes for multi-site sitecore solution

I have a multi-site sitecore solution. I want to have a coveo search page for each site, and have it search only the content of that site.

Do I… 1) Index all the sites in the master/web indexes, and filter them? - if so how do i filter the results to just show the current site? 2) Use a seperate master/web index for each site? - if so then how do i specify which indexes the search page should be using?

3 Replies
Gravatar for slangevin@coveo.com

Answer by Simon, May 20, 2015 1:09 PM

I would use filtering on the page itself, it will be easier to manage and more flexible. Use the filtering rules on the search component if you have the enterprise version, or the Coveo for Sitecore jQuery plugin if you are using the free version.

Enteprise: https://developers.coveo.com/pages/releaseview.action?pageId=21627258

Free: https://developers.coveo.com/display/public/SC201505/Adding+Filter+and+Boost+Expressions+Programmatically

You could also filter at the indexing level but I prefer at the search page level:

https://developers.coveo.com/display/public/SC201505/Controlling+What+Gets+Indexed+and+How

Cheers
Simon

Gravatar for micallahan@logmein.com

Comment by mcallahan, May 20, 2015 1:42 PM

Thanks! I can do this with javacript using the Site field, but that field contains too much info. This is what I need to do to get it to work…

Coveo.$('#search').on("buildingQuery", function(e, args) {
  args.queryBuilder.constantExpression.add("<%= ToCoveoFieldName("site") %>=='coveoanalytics;coveorest;login;admin;service;demo;scheduler;system;publisher'");
}).coveoForSitecore('init', CoveoForSitecore.componentsOptions);

Is that field supposed to contain the other site nodes from the web.config? Is there a way to do a .contain or .indexOf in the constantExpression?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 20, 2015 1:55 PM

You can set the site field ad a mulit-value field:

<fieldMap type="Coveo.SearchProvider.CoveoFieldMap, Coveo.SearchProvider">
  ...
  <fieldNames hint="raw:AddFieldByFieldName">
    ...
    <fieldType fieldName="site" isMultiValue="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
  </fieldNames>
  ...
</fieldMap>

You need to rebuild your Coveo indexes after this modification.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 20, 2015 1:57 PM

Then, you'll be able to query the "site" field with a single value:

args.queryBuilder.constantExpression.add('<%= ToCoveoFieldName("site") %>=="demo"');

The next step will be to code your helper method to get the current site name:

args.queryBuilder.constantExpression.add('<%= ToCoveoFieldName("site") %>=="<%= GetCurrentSiteName() %>"');
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, May 20, 2015 2:00 PM

For your information, in Coveo query syntax

  • @field=="value" is an exact match field query
  • @field="value" is a contains term field query

https://onlinehelp.coveo.com/en/ces/7.0/user/coveoquerysyntax_reference.htm

Gravatar for micallahan@logmein.com

Comment by mcallahan, May 20, 2015 2:18 PM

That worked!! Thank you Simon and jflheureux

Gravatar for sergi.dehesa@systelabsw.com

Answer by Sergi Dehesa, Jul 13, 2015 5:00 AM

  Coveo.$('#search').on("buildingQuery", function(e, args) {
                    args.queryBuilder.constantExpression.add("<%= ToCoveoFieldName("site") %> = '<%=Sitecore.Context.Site.Name%>'");
                }).coveoForSitecore('init', CoveoForSitecore.componentsOptions);

worked for me

Gravatar for sergi.dehesa@systelabsw.com

Answer by Sergi Dehesa, Jul 13, 2015 5:14 AM

I was wondering if it is possible to force a specific source for each site. I want to apply different Inbound Filters depending on the site so I need to have different indexes.

Model.IndexSourceName is read-only

Thanks in advance

Gravatar for slangevin@coveo.com

Comment by Simon, Jul 13, 2015 6:08 AM

You could create new indexes for all sites your sites. Adjust the start path in consequence.

Gravatar for sergi.dehesa@systelabsw.com

Comment by Sergi Dehesa, Jul 13, 2015 6:11 AM

Hello Simon, thanks for your answer. I know how to create indexes, but I don't know how to force the search box to look for specific source.

Gravatar for sergi.dehesa@systelabsw.com

Comment by Sergi Dehesa, Jul 13, 2015 6:39 AM

I started a new topic for this issue: https://answers.coveo.com/questions/3777/multi-site-sitecore-and-multiple-indexes

Ask a question