Flutter Firestore Composite Index with variable item not realistic? - flutter

I just created a StreamBuilder that has this stream:
stream: db
.collection('GearLockerItems')
.where('inPack.$packID', isEqualTo: true)
.orderBy('itemName')
.snapshots(),
When I ran the code, it didn't work at first, and when I checked the debug console. I saw a link I had to click and then it went and build a composite index and it worked!
But.... the composite index if for that specific variable $packID which means everytime I click on a new "pack" in my app to get this list, it wont work until I manually click to create the index....
This doesn't seem intuitive fro an app that lots of user could use, I can't manually index each item. Is there anyway around this or do I need to rething my entire db?

One way to solve this is to flatten the 'inPack.$packID' to be part of the document fields rather than inside an object.
Another is to list all possible options and create indexes for them, takes some time yes but gets the job done. I would not follow this approach as it will be prune to future errors if new packs are created and an index is not created for those. unless if you create a cloud function to automate the indexes creation. But again too many indexes will increase the size and will be counterproductive to "write operations" performance.
Also, take a look at this question as it is relevant to your case.
UPDATE:
Removed the suggestion about doing the composite indexes programmatically as it is not supported. For more details see this and this.

Related

React InstantSearch query different indexes with different data source(document)

How can I implement searching in different indexes with different data sources using a single search box? I am unable to switch <InstantSearch/>'s indexName(for example on button press to change index) without breaking the <Hits/> component because it is still retaining the previous hits.

Cypress / React-Admin table sort question

Looking for some inspiration here. I'm using react-admin, which is a material-ui based framework, with Cypress for e2e testing, and got stuck on table sorting.
There is a Cypress test within the react-admin github project to test for table sorting, but all it does is look at whether the up/down indicator appears after you click the table heading to toggle the sort. That's a UI test, not an end-to-end test, as it doesn't look at the actual data to see if the data is sorted.
In my case, when you change the sort order, an API request is made and the UI renders the new sorted data from the API.
However, although Cypress correctly checks for the content of the first row using .contains() before the sort, once the sort is done, Cypress still responds as if the first row in the table contains the same data, rather than the new data I can see on-screen. I've checked source, and the DOM is updated to the new order.
It's like there's some caching going on somewhere, and I can't figure out where.
I can't share the full code as it's complex and proprietary, but I've boiled it down to a minimal example, which is available at https://gitlab.com/notifium_public/cypress-table-sort
This uses react-admin's own demo site.
Just do:
git clone https://gitlab.com/notifium_public/cypress-table-sort.git
npm install
npm run test
then run the table_sort.js test in Cypress.
You'll see that test logs in, checks the first row, then clicks a column header and checks that first row again. The data is randomised, so the best check I could come up with is to check the new first row doesn't contain a customer with a "last seen" date in 2020.
Visually, the new entry in the top row will be 2016/2017, but the test fails, as it's still got a a reference to the original 2020 row.
Any thoughts?
Regards,
Andy

how to create a elastic watch which can identify the changes of data in a given index of elasticsearch

In the offical site of Elastic Watcher, they said
Watcher is a plugin for Elasticsearch that provides alerting and notification based on changes in your data
The relevant data or changes in data can be identified with a periodic Elasticsearch query
What I want is a function like Trigger of MySQL, that is when a record is updated, a action is triggered.
But I didn't find a example or document to address this use case, can anybody tell me how to do this?
You define an input of type search and using body, indices (mainly) you define which indices to look at (indices) and what is the actual query (body). If you need other settings, there are many more things to configure. After this, you define a condition and an action to complete the flow.
Make an attempt and create a watch. If you have difficulties, provide details of what you tried in a different SO post (you realize your current post is not appropriate for SO since you ask for complete code without you trying anything).

Visio 2013: How to trigger a change in databinding of all shapes

I have a nice process overview for our ordering process in Visio. I have an external data source (SQL Server), which works fine. Every record in my data source represents one ordering process. Currently all my shapes of the process are linked to the first record of the data source.
Now I want to add a dynamic behavior. What I want to achieve is this:
A user provides the order reference in a textbox (order reference is a column in the data source)
Afterwards the user clicks a button
After the button click, the process is updated and all shapes are now linked to the external data source record, that matches the provided order reference
So in short: the user should be able to select which process that needs to be visualized.
I assume that this is common functionality, but I don't see how I can deal with this requirement. I've searched already some days on this issue, but without any success.
Can you help me with this issue?
Thanks a lot!
Problem solved :-)
Some old school VBA was required. Using the DataRecordSet object did the trick. It contains a method GetDataRowIDs that you can use to query the external dataset. Once you have the record to visualize, it's just a matter of dynamically updating the shapes with the correct record. Use macro recording to see how to do this.
MSDN: http://msdn.microsoft.com/en-us/library/office/ms195694(v=office.12).aspx

What is the proper way to keep track of updates in progress using MondoDB?

I have a collection with a bunch of documents representing various items. Once in a while, I need to update item properties, but the update takes some time. When properties are updated, the item gets a new timestamp for when it was modified. If I run updates one at a time, then there is no problem. However, if I want to run multiple update processes simultaneously, it's possible that one process starts updating the item, but the next process still sees the item as needing an update and starts updating it as well.
One solution is to mark the item as soon as it is retrieved for update (findAndModify), but it seems wasteful to add a whole extra field to every document just to keep track of items currently being updated.
This should be a very common issue. Maybe there are some built-in functions that exist to address it? If not, is there a standard established method to deal with it?
I apologize if this has been addressed before, but I am having a hard time finding this information. I may just be using the wrong terms.
You could use db.currentOp() to check if an update is already in flight.