Search Interface Does Not Return the Expected Results in the Coveo for Salesforce Pro or Enterprise Edition

For the Coveo for Salesforce Free edition equivalent of this page, see Search Interface Does Not Return the Expected Results in the Coveo for Salesforce Free Edition.

Pro and Enterprise editions only

Symptoms

When querying your Coveo components, you get to the search page, and you either do not have access to results, or do not have all the results you expected to see.

There is also no error message displayed.

Causes

There are two possible causes for this:

  • The user you are using to query the component does not have access to those items. This is the expected behavior.
  • One of the filters for your search page is either too restrictive or invalid.

Resolution

To resolve this issue, you need to review the full query sent to the index, and perform the same query in the Coveo Cloud administration console.

Step 1 - Ensure the Item You Want Is Available in the Index

  1. Access the Administration Console of your Coveo Cloud organization (see Logging in to Coveo Cloud V2).
  2. Under Content, select Content Browser.
  3. To ensure you can see all available items, select the Preferences button () at the end of the search bar, and check the View all content box.
  4. Search for the item you want to see in your search results.
    1. If you can find it, you can continue to Step 2.
    2. If you cannot find it, your index does not contain the item you want to find. You thus need to review the way your sources are configured, and then rebuild them (see Adding and Managing Sources).

Step 2 - Get Your Search Page Full Query

  1. Access your search interface, and open your browser console in the Network tab.
  2. Perform a search on your page, which you would expect would return your desired results.
  3. You should see two XHR requests to platform.cloud.coveo.com, usually named v2/. Select the last one.
  4. In the Headers of the request, scroll to Form Data.
  5. The q, aq, cq, dq, and lq elements can all change which items should and should not be displayed in your search interface.

    Copy the value of all of those elements into the text editor of your choice.

    You will most likely not be able to find all of the previously listed elements in the Form Data. This is because when a value is empty, it is not sent.

  6. Back in the XHR request, still in the Headers section, scroll to the Request Headers section.
  7. Under Authorization, you should see an authorization token that looks like this: Bearer ey....

    Copy the full token, which starts with ey.

  8. Access JWT.io, and under Encoded, paste your token. You should see the decoded token under Decoded.
  9. In the Decoded section, if you have a filter element, copy its value and paste it in your text editor.

    Remember to change all instances of \" to ", as the quotation marks will not need to be escaped.

  10. You may want to note the userIds used in your search interface, as they might become useful later.
  11. In your text editor, add parentheses around the value of each element.

    This will serve as your base query.

In your search page, you find that your form data sends the following query:

q: mobile
aq: @objecttype==(Case, Knowledge)
cq: @language=="English" NOT @filetype=="Image"

Your token also has the following filter in its token:

@source==\"My Salesforce Source\"

Your base query would look like this:

(mobile) (@objecttype==(Case, Knowledge)) (@language=="English" NOT @filetype=="Image") (@source=="My Salesforce Source")

Step 3 - Test Your Query in the Content Browser

  1. Access your Coveo Cloud Content Browser again, as in Step 1 (see Step 1 - Ensure the Item You Want Is Available in the Index).

  2. In the search bar of the Content Browser, enter the base query you got from Step 2 (see Step 2 - Get Your Search Page Full Query).
  3. Perform the search with your base query.
    1. If you can find your item with the base query:
      1. You made a mistake copying your base query. Ensure you copied all the filters from your search page, and ensure it follows the Coveo Cloud query syntax (see Coveo Cloud Query Syntax Reference).
      2. The user of your search page does not have access to your item. You may need to verify that the users you got from the userIds element in your token has access to the item inside Salesforce, or whichever source your item comes from.
    2. If you cannot find your item with the base query, you may continue this procedure, as it is the expected outcome.
  4. Granularly remove parts of your query, until you have identified which part of the query is preventing your item from being returned.
  5. Once you have identified which part of the query is preventing the item from being returned, identify why it is not returned.

    Reasons might include: