[Feature] Only call Algolia under certain conditions
See original GitHub issueI’m using the query-parameters
in attributes in order to pass some filters to Algolia. I am using a reactive attributes to be able to change the query parameters.
<ais-index :query-parameters="param" app-id="latency" api-key="qq" index-name="movies">
[…]
...
data() {
return {
param: {}
}
},
mounted() {
// typically perform ajax call
this.param = { filters: 'genre:drama' };
}
In my actual app I’m call the my backend to be able to update the params
.
Algolia will before a first call without the filters
then when the params are updated, another call is performed. Since the ajax call is slow it creates a flickering effect.
I’d like to avoid the first call.
Here is a working example (it’s too fast so you’ll have to look at the XHR calls). https://codepen.io/julienbourdeau/pen/YQYZQw
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Conditional requests with InstantSearch.js - Algolia
This proxy lets you add some logic before calling the search method. In this case, you only call it when performing a query....
Read more >Implementing Rules - Algolia
Go to the Rules tab for a selected index and click on Add Rule. ... A Rule with filter values in the condition...
Read more >Rules overview - Algolia
Rules consist of three parts: conditions, consequences, and a validity period. Of these three parts, only the consequence is required.
Read more >Filtering | Algolia
Filtering allows your users to drill-down and create a smaller, more manageable set of data based on meaningful categories.
Read more >Search REST API Reference - Algolia
More formally: query N is executed only if all of queries 0 through N-1 had ... Perform multiple write operations in a single...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, so in that case, you must indeed call
stop()
on the store and callstart()
once you get your data.Internally the store keeps a counter of the number of times it was “stopped”, in a way that any part of your code can control wether to freeze or not the syncing with Algolia.
Here is a POC (not tested and jsfiddle doesn’t like es6 import but it gives you the main idea): https://jsfiddle.net/hmg1f15k/2/
Let me know if that doesn’t work/help @julienbourdeau
This is documented here: https://community.algolia.com/vue-instantsearch/getting-started/search-store.html#understanding-how-the-search-store-synchronizes-with-algolia