I’m using Custom Entities with Complex queries in my Forge app. When I save one entity and search for it by either normalizeName or UUID, the correct result comes back (one record). I then save 20 additional records, all with different names and UUIDs. After that, I once again perform the SAME search for the first record. No results come back. What’s going on here? I’d like to think I’m doing something wrong, but these feels like a bug. Adding additional records should not affect whether my original record is returned. In total, I have 21 records saved -a very small amount. I plan on having 10K-20K records saved. I hope this can scale to this volume.
storage:
entities:
- name: system
attributes:
name:
type: string
normalizedName:
type: string
uuid:
type: string
domain:
type: string
indexes:
- name
- normalizedName
- uuid
Here is how I do a parallel search across both indexes. It still fails when i just limit this to a single search over one index (in my testing).
async function searchSystems(searchVal: string) {
let systems = [];
console.log("Searching Systems for " + searchVal);
try {
const systemsByNamePromise = storage
.entity("system")
.query()
.index("normalizedName")
.andFilter("normalizedName", FilterConditions.contains(searchVal.toLowerCase()))
.sort(SortOrder.DESC)
// .limit(5)
.getMany()
const systemsByUuidPromise = storage
.entity("system")
.query()
.index("uuid")
.andFilter("uuid", FilterConditions.contains(searchVal))
.sort(SortOrder.DESC)
// .limit(5)
.getMany()
await Promise.all([ systemsByNamePromise, systemsByUuidPromise]).then(searchResults => {
console.log("handling search results: " + JSON.stringify(searchResults));
let allResults;
for(let i = 0; i < searchResults.length; i++) {
const resultObj= searchResults[i];
systems.push(...resultObj.results);
}
});
} catch (e) {
console.log("problem loading system entities: "+ e);
}
console.log("Returning found systems: " + JSON.stringify(systems));
return systems;
}
Also, if I include a LIMIT in the queries it can affect whether a result comes back -even though there is only a single record that matches!!! Something very strange is going on and right now it’s not reliable enough to use.