What will be the GPath expression for Rest Assured - rest-assured

I have tried to create GPath expression with filter criteria to return "my-notes" in list of object when '"my-type"' is SPECIAL
like : '"data.my-node.nodes.findAll{it.'my-type'=='GENERAL'}.'my-nodes'"'
but unable to get response from the below json
{
"data": {"my-node": [
{
"nodes": [ {
"my-nodes": [{"my-note": "abcdefg"}],
"my-type": "GENERAL"
}],
"my-instruction": null
},
{
"nodes": [ {
"my-nodes": [{"my-note": "abcdefg"}],
"my-type": "SPECIAL"
}],
"my-instruction": null
},
{
"nodes": [ {
"my-nodes": [{"my-note": "oiugitoirtuhou"}],
"my-type": "SPECIAL"
}],
"my-instruction": null
},
{
"nodes": [ {
"my-nodes": [{"my-note": "ifuoirjhihj"}],
"my-type": "SPECIAL"
}],
"my-instruction": null
},
{
"nodes": [ {
"my-nodes": [{"my-note": "idfgdiufgdhsfuihdf"}],
"my-type": "SPECIAL"
}],
"my-instruction": null
},
{
"nodes": [ {
"my-nodes": [{"my-note": "iydfgsigdfgdgidsf"}],
"my-type": "SPECIAL"
}],
"my-instruction": null
}
]}
}

Related

Spell corrections not working when refining queries with aggregations

I'm searching for list items using the /search/query endpoint of MS Graph. I want to use aggregations and spell checking. This is my request
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "inspring"
},
"fields": [
"title"
],
"aggregations": [
{
"field": "fileType",
"size": 20,
"bucketDefinition": {
"sortBy": "count",
"isDescending": "true",
"minimumCount": 0
}
}
],
"queryAlterationOptions": {
"enableModification": true
}
}
]
}
It returns no results, since the search term was not spell checked and modified:
{
"value": [
{
"searchTerms": [
"inspring"
],
"hitsContainers": [
{
"total": 0,
"moreResultsAvailable": false
}
]
}
],
"#odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.searchResponse)"
}
However, when I remove the aggregations and use the following request, it works:
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "inspring"
},
"fields": [
"title"
],
"queryAlterationOptions": {
"enableModification": true
}
}
]
}
Response:
{
{
"value": [
{
"searchTerms": [
"inspiring"
],
"hitsContainers": [
{
"hits": [...],
"total": 64,
"moreResultsAvailable": true
}
],
"queryAlterationResponse": {
"originalQueryString": "inspring",
"queryAlteration": {
"alteredQueryString": "inspiring",
"alteredHighlightedQueryString": "inspiring",
"alteredQueryTokens": [
{
"offset": 0,
"length": 8,
"suggestion": "inspiring"
}
]
},
"queryAlterationType": "modification"
}
}
],
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}
How do I have to change my request to make query alterations work with aggregations?

Elastic search - aggregation filter for product options

I have a products catalogue where every product is indexed as follows (queried from http://localhost:9200/products/_doc/1) as sample:
{
"_index": "products_20201202145032789",
"_type": "_doc",
"_id": "1",
"_version": 1,
"_seq_no": 0,
"_primary_term": 1,
"found": true,
"_source": {
"title": "Roncato Eglo",
"description": "Amazing LED light made of wood and description continues.",
"price": 3990,
"manufacturer": "Eglo",
"category": [
"Lights",
"Indoor lights"
],
"options": [
{
"title": "Mount type",
"value": "E27"
},
{
"title": "Number of bulps",
"value": "4"
},
{
"title": "Batteries included",
"value": "true"
},
{
"title": "Ligt temperature",
"value": "warm"
},
{
"title": "Material",
"value": "wood"
},
{
"title": "Voltage",
"value": "230"
}
]
}
}
Every option contains different value, so there are many Mount type values, Light temperature values, Material values, and so on.
How can I create an aggregation (filter) where I can let customers choose between various Mount Type options:
[ ] E27
[X] E14
[X] GU10
...
Or let them choose from different Material options displayed as checkboxes:
[X] Wood
[ ] Metal
[ ] Glass
...
I can handle it on frontend once the buckets are created. Creation of different buckets for these options is What I am struggling with.
I have succesfully created and displayed and using aggregations for Category, Manufacturer and other basic ones. Thes product options are stored in has_many_through relationships in database. I am using Rails + searchkick gem, but those allow me to create raw queries to elastic search.
The prerequisite for such aggregation is to have options field as nested.
Sample index mapping:
PUT test
{
"mappings": {
"properties": {
"title": {
"type": "keyword"
},
"options": {
"type": "nested",
"properties": {
"title": {
"type": "keyword"
},
"value": {
"type": "keyword"
}
}
}
}
}
}
Sample docs:
PUT test/_doc/1
{
"title": "Roncato Eglo",
"options": [
{
"title": "Mount type",
"value": "E27"
},
{
"title": "Material",
"value": "wood"
}
]
}
PUT test/_doc/2
{
"title": "Eglo",
"options": [
{
"title": "Mount type",
"value": "E27"
},
{
"title": "Material",
"value": "metal"
}
]
}
Assumption: For a given document a title under option appears only once. For e.g. there can exists only one nested document under option having title as Material.
Query for aggregation:
GET test/_search
{
"size": 0,
"aggs": {
"OPTION": {
"nested": {
"path": "options"
},
"aggs": {
"TITLE": {
"terms": {
"field": "options.title",
"size": 10
},
"aggs": {
"VALUES": {
"terms": {
"field": "options.value",
"size": 10
}
}
}
}
}
}
}
}
Response:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"OPTION" : {
"doc_count" : 4,
"TITLE" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "Material",
"doc_count" : 2,
"VALUES" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "metal",
"doc_count" : 1
},
{
"key" : "wood",
"doc_count" : 1
}
]
}
},
{
"key" : "Mount type",
"doc_count" : 2,
"VALUES" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "E27",
"doc_count" : 2
}
]
}
}
]
}
}
}
}

How do I pass output of one node as an input parameter to another node in Argo workflow DAG

I am trying to construct a ML pipeline DAG using Argo. And I am running into an issue where I need a value from one node in the DAG to be sent as a parameter to its subsequent node. Say the ARGO DAG structure looks like the following:
{
"apiVersion": "argoproj.io/v1alpha1",
"kind": "Workflow",
"metadata": {
"generateName": "workflow01-"
},
"spec": {
"entrypoint": "workflow01",
"arguments": {
"parameters": [
{
"name": "log-level",
"value": "INFO"
}
]
},
"templates": [
{
"name": "workflow01",
"dag": {
"tasks": [
{
"name": "A",
"template": "task-container",
"arguments": {
"parameters": [
{
"name": "model-type",
"value": "INTENT-TRAIN"
}
]
}
},
{
"name": "B",
"template": "task-container",
"dependencies": ["A"],
"arguments": {
"parameters": [
{
"name": "model-type",
"value": "INTENT-EVALUATE"
}
]
}
}
]
}
},
{
"name": "task-container",
"inputs": {
"parameters": [
{
"name": "model-type",
"value": "NIL"
}
]
},
"container": {
"env": [
{
"name": "LOG_LEVEL",
"value": "{{workflow.parameters.log-level}}"
},
{
"name": "MODEL_TYPE",
"value": "{{inputs.parameters.model-type}}"
}
]
}
}
]
}
}
A -> B
The computation happening in B depends on the value that has been computed in A.
How will I be able to pass the value computed in A into B?
You can use Argo's "artifacts" for this - see the examples at https://github.com/argoproj/argo-workflows/tree/master/examples#artifacts
Another way is to set up a shared volume: https://github.com/argoproj/argo-workflows/tree/master/examples#volumes

Cypher results return certain structure

I'm trying to return a certain structure.
Here is my query:
MATCH (tracker:tracker { active: true }) OPTIONAL MATCH (tracker { active: true })--(timer:timer) RETURN { tracker:tracker, timers:COLLECT(timer) } as trackers
Here is what I am returning so far:
{
"results": [{
"columns": ["trackers"],
"data": [{
"row": [{
"tracker": {
"title": "a",
"id": "04e3fddc-5aef-4c3a-9aeb-62a9fb15bd75",
"active": true
},
"timers": []
}]
}]
}],
"errors": []
}
I would like the timers to be nested under the "tracker" with the tracker's properties, like this:
{
"results": [{
"columns": ["trackers"],
"data": [{
"row": [{
"tracker": {
"title": "a",
"id": "04e3fddc-5aef-4c3a-9aeb-62a9fb15bd75",
"active": true,
"timers": []
}]
}]
}],
"errors": []
}
Try this:
MATCH (tr:tracker {active: true})
OPTIONAL MATCH (tr)--(ti:timer)
WITH {
title: tr.title,
id: tr.id,
active: tr.active,
timers: COLLECT(ti)
} as trackers
RETURN trackers

Cypher aggregation and collect

Given the following result in my cypher query, where people are a collection:
[
{
"people": [
{
"id": 24749,
"matches": 1
},
{
"id": 26026,
"matches": 1
},
{
"id": 26223,
"matches": 1
},
{
"id": 25121,
"matches": 1
},
{
"id": 24632,
"matches": 1
},
{
"id": 25708,
"matches": 1
},
{
"id": 25182,
"matches": 1
},
{
"id": 24826,
"matches": 1
},
{
"id": 26186,
"matches": 1
},
{
"id": 27001,
"matches": 1
},
{
"id": 24243,
"matches": 1
},
{
"id": 27255,
"matches": 1
},
{
"id": 27145,
"matches": 1
},
{
"id": 24126,
"matches": 1
},
{
"id": 27463,
"matches": 1
},
{
"id": 24069,
"matches": 1
},
{
"id": 25210,
"matches": 1
},
{
"id": 24994,
"matches": 1
},
{
"id": 27331,
"matches": 1
},
{
"id": 25793,
"matches": 1
},
{
"id": 27312,
"matches": 1
},
{
"id": 26206,
"matches": 1
},
{
"id": 24252,
"matches": 1
},
{
"id": 24714,
"matches": 2
},
{
"id": 24612,
"matches": 1
},
{
"id": 26964,
"matches": 1
},
{
"id": 27101,
"matches": 1
},
{
"id": 26730,
"matches": 1
},
{
"id": 27211,
"matches": 1
},
{
"id": 24783,
"matches": 2
},
{
"id": 25336,
"matches": 1
},
{
"id": 24128,
"matches": 1
},
{
"id": 26186,
"matches": 1
},
{
"id": 25125,
"matches": 2
},
{
"id": 24069,
"matches": 3
},
{
"id": 24607,
"matches": 1
},
{
"id": 27055,
"matches": 1
},
{
"id": 25336,
"matches": 3
},
{
"id": 24128,
"matches": 2
},
{
"id": 26716,
"matches": 1
},
{
"id": 27331,
"matches": 1
},
{
"id": 24069,
"matches": 1
}
]
}
]
How can I (with cypher) iterate the people collection and find the ones with the same "id", sum the "matches" items together and then add a new item called "duplicates" or similar.
Example result I'm trying to get:
[
{
"people": [
{
"id": 24069,
"matches": 5, // all the "matches" of the duplicate 24069's added together
"duplicates": 3 // how may times the id 24069 was found in the collection called people
},
// etc...
]
}
]
The query:
match (p:people) return distinct(p.id),sum(p.matches)
should probably give you what you need
This is kinda complicated, as the simplest way is to tear your collection apart and reassemble it. It's a lot of steps, but here is the Cypher to do that as well as comments on what each step is doing.
// initial matching (whatever you match on to get your collection)
MATCH (n:People) WITH collect(n) as people
// Tear people collection apart for possessing
UNWIND people as p
// Reduce on id
WITH COLLECT(DISTINCT p.id) as id, p.matches as m
// For each id, sum and count the matches
WITH {id:id, matches:SUM(m), duplicates:COUNT(m)} as people
// Recollect rows into collection
RETURN COLLECT(people) as people

Resources