Gravatar for

Question by Scott Hoffman, May 1, 2017 8:10 PM

How to switch to web index for rest results in view rendering

When using /sitecore/layout/Models/Coveo/Search Model, and the ToCoveoFieldName method from that model, the aq that is used references the master index identifier. eg., aq=%40fisz32xarticlez32xpage34822%3D1, where 34822 is the number used by my local master index.

How can we switch out that number, since are default pipeline is filtering out items from anything but the web index, this means we won't see any results.

I've tried this both within content editor, and in an incognito window.

Gravatar for

Comment by François Lachance-Guillemette, May 1, 2017 8:33 PM

Hi Scott,

I don't think you should filter out items from anything but the web index in your pipeline. The hash is used specifically for that purpose, it should work OOTB without the pipeline filter.

Why is the pipeline configured that way?

1 Reply
Gravatar for

Answer by François Lachance-Guillemette, May 2, 2017 2:56 PM

The hash mechanic serves the purpose of isolating your environments.

Coveo for Sitecore uses the current context item to get which environment it should target. Meaning a search page within the master database should return items from the master database, and the same thing happens with the web database. This way, the environments stay separated and have no impact on each other.

`ToCoveoFieldName` translates fields into a field name that is _only_ available in one environment. This way, a simple filter on any field like `@fisz32xarticlez32xpage34822` should only return documents from that environment.

The simple act of adding a query with any of those translated fields should give you the items you need, thus not requiring any pipeline to filter items to return only those in one environment.

So I really think the right way to solve your problem would be by:

  1. Removing the filter that only gets Web items
  2. Adding a simple query with a translated field to separate the environments (which you already do with `@fisz32xarticlez32xpage34822`)

Let us know if this works for you or if you need any further help.

Gravatar for

Comment by Scott Hoffman, May 2, 2017 3:04 PM

I would agree with your comments, however, all we have in our razor view is this code:

data-expression="@Model.ToCoveoFieldName("Is Article Page", true)=1", so Coveo is choosing the index for me. How do we specify the master or web items from this call or do we change something in the config?

Ask a question