Search interface does not return the expected results

In this article

Symptoms

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

There’s also no error message displayed.

Causes

There are two possible causes for this:

  • The user you’re using to query the component doesn’t 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 Administration Console.

Step 1: Ensure that the item you want is available in the index

Log in to Coveo (platform-ca | platform-eu | platform-au).

  1. Under Content, select Content Browser.

  2. To ensure that you can see all available items, click (Preferences) at the end of the search bar, and check the View all content box.

  3. 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 can’t find it, your index doesn’t contain the item you want to find. Therefore, you need to review the way your sources are configured, and then rebuild them (see Manage 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 requests to platform.cloud.coveo.com, usually named v2/. Select the last one.

  4. In the Payload of the request, scroll to Form Data.

  5. The q, aq, cq, dq, and lq elements can all change which items should and shouldn’t 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’s not sent.

  6. Back in the request, in the Headers tab, 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 won’t 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 the Coveo Administration Console Content Browser (platform-ca | platform-eu | platform-au) .

  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 that you copied all the filters from your search page, and ensure it follows the query syntax.

      2. The user of your search page doesn’t 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 can’t find your item with the base query, you may continue this procedure, as it’s 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’s not returned.

    Reasons might include: