How Are Results Generated

Hi -

On a store locator page, I am using a custom button to handle queries that are input by a user. What should happen is that types in a city, for example, a list of store results near that city are displayed (using verticalResults component).This button seems to be working except I noticed that if a user inputs a city where there are no stores or even a random term such as “bananas”, a list of results are returned that are near the location of the user. What should happen is there should be zero results.

Do you have any insight on why this happens and where I can change it? So far I am able to view the results array but I’ve not been able to determine where I can view how results are being generated so that I can modify it. Please let me know.

Hey Zuri,

There is a displayAllOrNoResults prop on the <VerticalResults> component which controls this behavior.

By default, when a query returns no results, the component will render a list of suggested results from that vertical. You can override this behavior like so:

<VerticalResults
  CardComponent={StandardCard}
  displayAllOrNoResults={false}
/>

Hope this helps!
DJ

Thanks DJ, I’ve used the dispalayAllOrNoResults prop but still get the same default behavior. The issue from what I’m seeing is that the query (even if there are no locations that match it) always returns results. Results is never an empty array. It seems like by default, it always returns results that are near the user. So I’m looking for where I can change that. Can you maybe points me to what triggers the results to generate? Or how to set results to equal zero maybe and I can build a custom function.