Ordering Search Results
Pearson similarity overview and problem statement
In this section you will improve the display of search results. When a user searches for businesses we want to order the results so that we show the most relevant results first. To do that, you will use the Pearson similarity metric.
Let’s look at the part of the application that you will enhance.
In the CodeSandbox Browser, you can select Business Search, and search for Pizza in the category Restaurants.

Instead of showing results in alphabetical order you will modify the application to show the most relevant businesses first.
Useful Resources
|
Exercise
You will update the application to use this new information.
Instead of selecting the reviews for our businesses based on the opinions of users unrelated to user-name
, we’ll show reviews written by similar users.
-
In Neo4j Browser, perform the steps in Neo4j Browser guide section Search Results. (:play applied_graph_algorithms/03_search_results.html)
-
In CodeSandbox, edit the Cypher query in
src/exercises/exercise2.js
to return businesses. -
Save this file.
-
In the CodeSandbox Browser, select a user from the User Profile drop down. This will set this user for the search.
-
Select Business Search, entering pizza for the search text and select Restaurant for the category. You should see a list of restaurants that are relevant to that user.
-
Select a different user and then search for pizza restaurants. You should see a different set of restaurants.
This query should be in the context of the currently "logged in" user in the application. Since our simple application doesn’t have any authentication mechanism we fake this by choosing a user in the dropdown in the "User Profile" section of the application. The id of the currently logged in user will be available as a Cypher parameter So for example, to find the currently logged in user:
|
Solution
If you get stuck, watch this video for a walk-through of the solution:
Ordering search results solution
Check your understanding
Need help? Ask in the Neo4j Community