-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: Refresh search using same query parameters #1173
Comments
You can try with the |
Is it possible to do the same with ReactiveList? |
@bietkul I wasn't able to make updateQuery work with the same query I think this line is preventing it: |
If anyone wonders I solved it by making the query different but ensuring that it returns the same results defaultQuery={() => ({
timeout: '1s',
query: {
bool: {
must: filter,
should: [{
term: {
dummy: String(lastRefreshTime)
}
}]
}
}
})} Where dummy is an attribute that doesn't exist and lastRefreshTime is the time where the server was updated. Anyway I think it should be a better way to update the data when the user presses a refresh button or the app knows that the query could return different data. |
@z4m0 i can't seem to get your |
I'm interested by that. I'm doing a checker to verify if we have new fresh data, and display a button to the user in order to click it and refresh the whole reactive search context. Is there a good way to do that? |
const Refresher = ({ defaultQuery }) => {
const [refreshingDate, setRefreshingDate] = useState(Date.now())
const handleClick = () => {
setRefreshingDate(Date.now())
}
return (
<ReactiveComponent
componentId="refresher"
customQuery={() =>
bodybuilder()
.notFilter("term", "DJPZ6h5jYFlNWv22", refreshingDate) // this field should not exist, it's just a way to trigger reactive search
.build()
}
render={() => (
<button type="button" onClick={handleClick}>
Click me
</button>
)}
/>
)
} and you only need to add It creates a bigger elastic search query but it works. I didn't find yet a better way to do that. |
This is how I did the refresh with ReactiveComponent which also contains custom index query (not needed if you only refresh).
and use it in other components
To refresh, simply call |
@bietkul |
Affected Projects
React
Is your feature request related to a problem? Please describe.
I'm looking for a way to force a refresh of the elasticsearch query using the same active set of search parameters since my database may be updated fairly frequently and I don't want to force the user to refresh the page. After searching through the docs and issues I haven't found a clear way to do this. Is this functionality supported?
The text was updated successfully, but these errors were encountered: