The following logic app is triggered at 10 AM and runs a SQL server query.
As you can tell from the picture the resultsets are empty.
The conditional check checks whether the resultssets of the query is empty. (2nd pic)
How does this still translate into a True? The result is clearly empty.
With your condition, you are trying to compare an array to a boolean.
Instead you could check if the length of the array is not equal to 0:
{
"Condition": {
...
"expression": {
"and": [
{
"not": {
"equals": [
"#length(body('query')?['resultsets'])",
0
]
}
}
]
},
...
}
}
Anyway, I found another way.
For future refence my solution was as follows:
"Compose": {
"inputs": "#empty(body('query')?['resultsets'])",
"runAfter": {
"query": [
"Succeeded"
]
},
"expression": {
"and": [
{
"equals": [
"#outputs('Compose')",
"#true"
]
}
]
}
Related
I'm starting to test ArangoSearch to use in an upcoming feature. I have a nested JSON field that I want to do a token search on a nested field.
{ip:{dpdm:{description:<text>}}}
The view is:
{
"writebufferIdle": 64,
"type": "arangosearch",
"writebufferSizeMax": 33554432,
"consolidationPolicy": {
"type": "tier",
"segmentsBytesFloor": 2097152,
"segmentsBytesMax": 5368709120,
"segmentsMax": 10,
"segmentsMin": 1,
"minScore": 0
},
"primarySort": [],
"globallyUniqueId": "h7437427BB0F0/26371461",
"id": "26371461",
"storedValues": [],
"writebufferActive": 0,
"consolidationIntervalMsec": 1000,
"cleanupIntervalStep": 2,
"commitIntervalMsec": 1000,
"links": {
"pmconfig": {
"analyzers": [
"identity"
],
"fields": {
"ip.dpdm.version_notes": {
"analyzers": [
"text_en"
]
},
"ip.digital.feature_list": {
"analyzers": [
"text_en"
]
},
"ip.common.Available-Views": {
"analyzers": [
"text_en"
]
},
"ip.pipeline.comment": {
"analyzers": [
"text_en"
]
},
"ip.dpdm.eccn": {
"analyzers": [
"text_en"
]
},
"ip.dpdm.description": {
"analyzers": [
"text_en"
]
},
"ip.dpdm.maturity_comments": {
"analyzers": [
"text_en"
]
}
},
"includeAllFields": true,
"storeValues": "none",
"trackListPositions": false
}
},
"primarySortCompression": "lz4"
}
The following query return 58 objects:
for d in pmconfig filter d.ip.dpdm.description like('% synchronous %') return d
But the following doesn't return any items:
for d in v_myView search analyzer(d.ip.dpdm.description in tokens('synchronous', 'text_en'), 'text_en') return d
I'm sure I did something wrong but it looks right to me. A pointer to get me going would be appreciated.
I knew I was missing something. Looks like I shouldn't use nested field paths when specifying the view. All I needed to do was to set the top level field "ip" to the "text_en" analyzer in the view. All is good now.
I have the following view in CouchDB that is reduced via _count:
function (doc) {
if (doc.type === "signature") {
emit([doc.worksite_id, doc.uid, doc.timestamp], doc._id);
}
}
There are cases where rather than using group_level=2 in my query to get my count values sorted by doc.worksite_id and doc.uid pairs (as shown below)...
{
"rows": [
{
"key": [
"worksite-1",
"id-1"
],
"value": 2
},
{
"key": [
"worksite-2",
"id-1"
],
"value": 1
},
{
"key": [
"worksite-2",
"id-2"
],
"value": 26
}
]
}
...I, instead, need to get count values sorted strictly by doc.uid, with an example of something similar to the following:
{
"rows": [
{
"key": [
"id-1"
],
"value": 3
},
{
"key": [
"id-2"
],
"value": 26
}
]
}
Is there an efficient way to do this based on the current view I'm querying from? And if not, what is the most efficient way to do this?
Please don't tell me to "googleit"!
I have been poring over the Apache pages and the IBM pages for days trying to find the full allowed syntax for a Design Doc.
From the above readings:
the 'map' property is always a Javascript function
the 'options' property may be one/both of local_seq or include_design.
When I use Fauxton to edit a Mango Query, however, I see that the reality is much broader.
I defined a query ...
{
"selector": {
"data.type": {
"$eq": "invoice"
},
"data.idib": {
"$gt": 0,
"$lt": 99999
}
},
"sort": [
{
"data.type": "desc"
},
{
"data.idib": "desc"
}
]
}
... with an accompanying index ...
{
"index": {
"fields": [
"foo"
]
},
"name": "foo-json-index",
"type": "json"
}
... and then looked at the design doc produced ...
{
"_id": "_design/5b1cf1be5a6b7013019ba4afac2b712fc06ea82f",
"_rev": "1-1e6c5b7bc622d9b3c9b5f14cb0fcb672",
"language": "query",
"views": {
"invoice_code": {
"map": {
"fields": {
"data.type": "desc",
"data.idib": "desc"
},
"partial_filter_selector": {}
},
"reduce": "_count",
"options": {
"def": {
"fields": [
{
"data.type": "desc"
},
{
"data.idib": "desc"
}
]
}
}
}
}
}
Both of the published syntax rules are broken!
map is not a function
options defines the fields of the index
Where can I find a full description of all the allowed properties of a Design Document?
Cloudant is returning error message:
{"error":"invalid_key","reason":"Invalid key use-index for this request."}
whenever I try to query against an index with the combination operator, "$or".
A sample of what my documents look like is:
{
"_id": "28f240f1bcc2fbd9e1e5174af6905349",
"_rev": "1-fb9a9150acbecd105f1616aff88c26a8",
"type": "Feature",
"properties": {
"PageName": "A8",
"PageNumber": 1,
"Lat": 43.051523,
"Long": -71.498852
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-71.49978935969642,
43.0508382914137
],
[
-71.49978564033566,
43.052210148524
],
[
-71.49791499857444,
43.05220740550381
],
[
-71.49791875962663,
43.05083554852429
],
[
-71.49978935969642,
43.0508382914137
]
]
]
}
}
The index that I created is for field "properties.PageName", which works fine when I'm just querying for one document, but as soon as I try for multiple ones, I would receive the error response as quoted in the beginning.
If it helps any, here is the call:
POST https://xyz.cloudant.com/db/_find
request body:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
},
"use-index": "pagename-index"
}
In order to perform an $or query you need to create a text (full text) index, rather than a json index. For example, I just created the following index:
{
"index": {
"fields": [
{"name": "properties.PageName", "type": "string"}
]
},
"type": "text"
}
I was then be able to perform the following query:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
}
}
I have an index of documents that look this:
{
url: "/foo/bar",
html_blocks: [
"<h1>hi</h1>"
],
tags: [
"video",
"text"
],
title: "My title"
}
I'd like to query these documents on the title and html_blocks fields, and for any matches add a boost if they have a video tag.
So far, my query looks like this:
{
"query": {
"query_string": {
"query": "foo",
"fields": [
"title",
"html_blocks"
]
}
}
}
How do I modify it so that it continues to only return results if a match is found in the existing query, but a boost is added to any of the results which have a video tag? Thanks!
You want a custom_filters_score which will just boost on matches. Note that filter input is not analyzed, so you might wrap that in a query if you need it analyzed. Your other options to boost, while not really for this case are the boosting query, which is good for demoting results and the custom_score_query which is good for added boosts based on some calculated value.
See: Custom_filters_score
{
"query": {
"custom_filters_score": {
"query": {
"query_string": {
"query": "foo",
"fields": [
"title",
"html_blocks"
]
}
},
"filters": [
{
"filter": {
"term": {
"tags": "video"
}
},
"boost": 3
}
]
}
}
}
Edit:
This is what I mean by wrapping in a query using a filter query. Trust me, once you get the hang of ES, you'll be nested so knee deep that you'll produce some of the most satisfying queries ever.
{
"query": {
"custom_filters_score": {
"query": {
"query_string": {
"query": "foo",
"fields": [
"title",
"html_blocks"
]
}
},
"filters": [
{
"filter": {
//here comes the filter query, and I changed term to match
//since match analyzes
"query":{
"match": {
"tags": "video"
}
}
},
"boost": 3
}
]
}
}
}