Search interface does not return the expected results
Search interface does not return the expected results
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 the Coveo Platform and go to the Content Browser (platform-ca | platform-eu | platform-au) .
-
To ensure that you can see all available items, click () at the end of the search bar, and check the View all content box.
-
Search for the item you want to see in your search results.
-
If you can find it, you can continue to Step 2.
-
If you can’t find it, it may not be in your index. Review your source configuration to make sure it’s indexed, and then launch a rebuild.
-
Step 2: Get your search page full query
-
Access your search interface, and open your browser console in the Network tab.
-
Perform a search on your page, which you would expect would return your desired results.
-
You should see two requests to
platform.cloud.coveo.com
, usually namedv2/
. Select the last one. -
In the Payload of the request, scroll to Form Data.
-
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.
-
Back in the request, in the Headers tab, scroll to the Request Headers section.
-
Under Authorization, you should see an authorization token that looks like this:
Bearer ey...
.Copy the full token, which starts with
ey
. -
Access JWT.io, and under Encoded, paste your token. You should see the decoded token under Decoded.
-
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. -
You may want to note the
userIds
used in your search interface, as they might become useful later. -
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
-
Access the Coveo Administration Console Content Browser (platform-ca | platform-eu | platform-au) .
-
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).
-
Perform the search with your base query.
-
If you can find your item with the base query:
-
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.
-
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.
-
-
If you can’t find your item with the base query, you may continue this procedure, as it’s the expected outcome.
-
-
Granularly remove parts of your query, until you have identified which part of the query is preventing your item from being returned.
-
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:
-
The query is wrongly formatted (see Query syntax).
-
A particular field value on your item is preventing it from being returned (see Inspecting items with the Content Browser).
-
The item shouldn’t appear to the user in the first place.
-