# Refresh Search result without altering the state

**URL:** <https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [April 27, 2022, 11:05am UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392 "2022-04-27T11:05:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_Lemine\_Ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lemine_ahmed/32/104874_2.png) [@Mohamed\_Lemine\_Ahmed](https://discuss.elastic.co/u/Mohamed_Lemine_Ahmed)\
**Post date:** [April 27, 2022, 11:05am UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/1 "2022-04-27T11:05:57Z")

</div>

Hi everyone  
Is there any way I can refresh the search results without altering the search state, it would great if such feature would exist, As I tried to do it by exporting the SearchDriver but I didn't succeed.

Please this is a cry for help situation.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [April 27, 2022, 8:02pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/2 "2022-04-27T20:02:49Z")

</div>

The search state should all be persisted to the URL, so refreshing the page will maintain the state.

---

<div class="post-metadata">

**Author:** ![Mohamed\_Lemine\_Ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lemine_ahmed/32/104874_2.png) [@Mohamed\_Lemine\_Ahmed](https://discuss.elastic.co/u/Mohamed_Lemine_Ahmed)\
**Post date:** [April 27, 2022, 8:22pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/3 "2022-04-27T20:22:52Z")

</div>

You’re saying that I should refresh the page. Can I refresh the results without refreshing the page??

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [April 27, 2022, 9:40pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/4 "2022-04-27T21:40:46Z")

</div>

Sorry, I think I misunderstood. Why do you want to refresh the search results without updating the search state, I don't think I understand.

---

<div class="post-metadata">

**Author:** ![Mohamed\_Lemine\_Ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lemine_ahmed/32/104874_2.png) [@Mohamed\_Lemine\_Ahmed](https://discuss.elastic.co/u/Mohamed_Lemine_Ahmed)\
**Post date:** [April 27, 2022, 10:58pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/5 "2022-04-27T22:58:29Z")

</div>

Let me give you an example. I want to delete an item after a search has been made, when I delete that item I want the search results to update, so here I am not altering the search state I’m not adding anything just want the result to update. how can I do that without refreshing the page ?

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [April 28, 2022, 12:09pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/6 "2022-04-28T12:09:37Z")

</div>

Ah, got it.

1. First, make sure "cacheResponses" is set to false on your App Search connector: [App Search Connector | Elastic Docs](https://docs.elastic.co/search-ui/connectors-api/app-search-connector#additional-options)
2. Second, there is no explicit action to refresh, but you can refresh by calling [setSearchTerm](https://docs.elastic.co/search-ui/api/actions#setsearchterm) with the current [searchTerm](https://docs.elastic.co/search-ui/api/state#request-state).

If you aren't already using the React API directly, you access these things through something like the `WithSearch` HOC: [Connectors | Elastic Docs](https://docs.elastic.co/search-ui/api/react/hocs#withsearch-1)

```auto
<SearchProvider config={config}>
  <WithSearch
    mapContextToProps={({ searchTerm, setSearchTerm }) => ({
      searchTerm,
      setSearchTerm,
    })}
  >
    {({ searchTerm, setSearchTerm }) => (
      <div className="App">
        <button onClick={() => setSearchTerm(searchTerm)}></button>
      </div>
    )}
  </WithSearch>
</SearchProvider>

```

Hope that helps. I wish we had a better way to do this!

---

<div class="post-metadata">

**Author:** ![Mohamed\_Lemine\_Ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohamed_lemine_ahmed/32/104874_2.png) [@Mohamed\_Lemine\_Ahmed](https://discuss.elastic.co/u/Mohamed_Lemine_Ahmed)\
**Post date:** [April 28, 2022, 12:30pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/7 "2022-04-28T12:30:49Z")

</div>

> [@JasonStoltz](#):
>
> cacheResponses

That what I've been missing the cacheResponses attribute, you should really emphasise the use of this configuration attribute in your docs , as I didn't find any mention of it and its really a necessary attribute.

Thank you so much, you save my day.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [April 28, 2022, 1:16pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/8 "2022-04-28T13:16:59Z")

</div>

That's good feedback, we will definitely do that, thank you!

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [April 28, 2022, 1:17pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/9 "2022-04-28T13:17:42Z")

</div>

Perhaps that should be an opt-in optimization rather than an opt-out.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 26, 2022, 1:18pm UTC](https://discuss.elastic.co/t/refresh-search-result-without-altering-the-state/303392/10 "2022-05-26T13:18:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
