Error: FAILED_PRECONDITION: no matching index found. recommended index is: - node.js

So I'm trying to run a query on Google Cloud's datastore as such:
let query = datastore.createQuery(dataType)
.select(["id", "version", "lm", "name"])
.filter("owner", "=", request.params.owner)
.filter("lm", ">=", request.query.date_start)
.groupBy(["lm"])
.order("lm")
Yet I run into an error stating that
no matching index found. recommended index is:
- kind: Entry
properties:
- name: lm
- name: id
- name: name
- name: version
When I run the query with id instead of lm for all the methods I run into no errors.
Is this because in my index.yaml file I have the index as such: ?
- kind: Entry
properties:
- name: id
- name: version
- name: lm
- name: name
Must I actually create a new index with the recommended ordering? Or is there a way I can do this without having to make another index? Thank you!

Yes, you need to create a new index, the existing one you showed is not equivalent, so it can't be used for your query - the property order matters (at least for the inequality filters and sorting). See related Google Datastore Composite index issue

Related

MQL: checking for present value / optional

As in title i ask for optional or dynamic value presence check in script, my goal is only to combine 2 metrics of same type, so joining them would be also a solution.
I have 2 different routs for same metrics, getting answere only from one of them at a time. I'd like to group them into one dashboard like:
fetch container |
{ metric custom.googleapis.com/http/.../count;
metric custom.googleapis.com/http/joe/.../count }
| join
I tried different combinations, outer_join 0 seemed closest, but having no traffic in one of routs causes:
> Input table 1 does not have time series identifier column
> 'metric.requestType' that is present in table 0.
NOTE: One endpoind is NOT connected at all for a period of time
Configurationin similar for each in metrics.yaml:
---
apiVersion: monitoring.cnrm.cloud.google.com/v1beta1
kind: MonitoringMetricDescriptor
metadata:
labels:
app: << app_name >>
name: custom/http/client/custom/requests/count
namespace: << project_name >>
spec:
type: custom.googleapis.com/http/client/custom/requests/count
metricKind: GAUGE
valueType: INT64
labels:
- key: pod_name
You might be able to try outer_join 0,0. I've not tested this, but the suggestion was taken from https://stackoverflow.com/a/70595836 which states that it will substitute zeros if either stream's value is missing. There's a couple of variations on this depending on what you want to do.

SuiteScript - Search joining "Term" from "Vendor"

I am doing a search of vendors and want to join in the Term to have the Term's name. The vendor has a field called terms which has the internalid of the Term. Term has a field called name which contains what I'm looking for.
I've tried just about every combination of building the column but I always get an error:
An nlobjSearchColumn contains an invalid column join ID, or is not in proper syntax: name.
Example of how I'm building the column:
search.createColumn({
name: "name",
join: "terms", // or Term, or Terms, none of it works
label: "termname" // or leave this out or Term or Terms or anything else nothing works
}
What is the right way to create a search for vendor that also includes the term's name?
If you'll look at the Records Browser, terms is not listed as a join on the vendor record. Just get terms as a column (name: 'terms') then when you retrieve the result, use getText instead of getValue.
searchResults[i].getText({
name: 'terms'
});

Nested findall() with ‘case’ equivalent to include statement

I am very new to APIs (a week in) and I’m stuck with a challenge.
I have tables in Postgres and have created models for each. There is a link from one to another (in some circumstances). If the link doesn’t exist then I want to use a default value, held in a different table.
Example:
Table - items
- id (int)
- name (text)
- startDateTime (date)
- endDateTime (date)
Table - itemTypes
- id (int)
- name (text)
- isDefault (boolean)
Table - itemTypesLinkItems
- id (int)
- itemsId (int)
- itemTypesId (int)
- fromDateTime (date)
- toDateTime (date)
At any given date, there will be a list of items that display. Some of those might be linked to itemTypes via the itemTypesLinkItems table, and so I can show the itemTypes.Name. For the remainder, I’d like to show the itemTypes.Name value where the isDefault = true.
I’ve searched all over, tried to do it with SQL views, but no luck. I’m hoping this is something that can be done within the JavaScript of the API.
router.get(‘/:date’, (req, res) =>
db.items.findAll()({
include: [
{
model: db.itemtypelinkitem,
required: false,
include: [
{
model: db.itemtypes
}
]
where: {
startDateTime: {[Op.lte]: req.params.date},
endDateTime: {[Op.gte]: req.params.date}
}
}
]
I just don’t know where to go from here. If I exclude the ‘required’ then only those items with a link are returned. If I include it, then they all show and if there is a link it returns the details, otherwise just returns []. In the event that it returns a [], I’d like to replace that with the values from the default itemTypes.
I hope understood your question well.
You made many to many Relation between (items, itemTypes) and want to get a default
itemType when getting all items.
so I think this problem not related to Sequlize.
You have to insert default 'itemType' while inserting a new record into 'items' table.

Complex script for bulk/update a document without getting it

I have for my project, this ES mapping representation :
- BOOK
- label: String,
- active: Boolean
- total_term_occ: Long
- TERMS
- label: String,
- ngram: Byte,
- tot_occurrences: Long,
- books [{
- id: String,
- label: String,
- occurrences: Long,
- tfidf: Double
}]
For each new term (ex: "ES rocks"), I want to :
- Update the total occurrence in the "TERMS" doc
OR
- Create the new term if not exists
AND (if term already exists)
- BOOK :
- Create a new object if the book does not already exist with "occurrences" to 0 and "tfidf" to NULL
OR
- Update the "occurrences" field if the book exists (with a loop ?!)
I want to make a bulk request "update -> script -> upsert" but without getting the document before updating it.
Do you think this is possible with the choice of mapping ? I can't find a good solution....

DocumentDB - Cannot compare two paths in query

Microsoft Azure Documents BadRequestException An invalid query has been specified with filters against path(s) that are not range-indexed. Consider adding allow scan header in the request.
My query is:
SELECT c.id FROM users c WHERE (c.lat < 29.89)
OVER ?? number of documents (as there are no way to get the number of document in collection with DocumentDB)
If you look at the blogpost here:
http://azure.microsoft.com/blog/2015/01/27/performance-tips-for-azure-documentdb-part-2/
Indexing Policy Tip #3: Specify range index path type for all paths
used in range queries
DocumentDB currently supports two index path types: Hash and Range.
Choosing an index path type of Hash enables efficient equality
queries. Choosing an index type of Range enables range queries (using
>, <, >=, <=).
It gives an example in C# to add a Range Index to make the path comparable, but there is similar functionality in the node.js library.
When you create a collection, you can pass the IndexingPolicy through the body parameter. The IndexingPolicy has a couple of members. One of which is the IncludedPaths, where you can define indices.
var policy = {
Automatic: true,
IndexingMode: 'Lazy',
IncludedPaths: [
{
IndexType: "Range",
Path: "path to be indexed (c.lat)",
NempericPrecission: "1",
StringPrecission: "1"
}
],
ExcludedPaths: []
}
client.createCollection(
'#yourdblink',
{
id: 10001,
indexingPolicy: policy
});
The Policy can be changed in the new Azure Portal (https://portal.azure.com), under (your DocumentDB resource) -> Settings -> Indexing Policy.

Resources