asset shipment identified by shipId{
o string shipId
o TemperatureThresholdEvent[] temperatureReading
}
event TemperatureThresholdEvent{
.....
}
I'm trying to have Array of TemperatureThresholdEvent in Shipment Asset. Is the model declaration valid?
You can create an Array of the event in model file. It will work as an only Array field.
Example:
namespace org.example.basic
asset SampleAsset identified by assetId {
o String assetId
--> SampleParticipant owner
o String value
o SampleEvent[] sampleEvent
}
Created Asset Contain:
{
"$class": "org.hyperledger.composer.system.AddAsset",
"resources": [
{
"$class": "org.example.basic.SampleAsset",
"assetId": "4467",
"owner": "resource:org.example.basic.SampleParticipant#7145",
"value": "Esse laboris quis consectetur.",
"sampleEvent": [
{
"$class": "org.example.basic.SampleEvent",
"asset": "resource:org.example.basic.SampleAsset#5945",
"oldValue": "Proident aliqua id ex.",
"newValue": "Esse ex aliqua exercitation sit.",
"eventId": "6719",
"timestamp": "2019-09-26T05:08:12.554Z"
}
]
}
],
"targetRegistry": "resource:org.hyperledger.composer.system.AssetRegistry#org.example.basic.SampleAsset",
"transactionId": "7ecd4664-c0d2-4b56-871e-6ff1ae9c4b56",
"timestamp": "2019-09-26T05:08:20.448Z"
}
Related
am generating enties some thing like below, Person
entity Employee {
firstName String
lastName String
}
entity Role {
Name String
}
relationship OneToMany {
Employee{role} to Role{employee required}
}
The generated Employee does not include the RoleDTO. I would like it to return the following:
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"roles":
[
{
"id": 1
"name": "Admin"
},
{
"id": 2
"name": "Collector"
}
]
}
But the DTO generated are working other ways round.
Role is having List of EmployeeDTO's.
Manual Code change is one option,but in my project i have alsmot 40 entities and this mdoification has to be done for almost all entities. In that case Jhispter is generated code is not usefull any more.
I use the Azure Search indexer to index documents from a MongoDB CosmosDB which contains objects with fields named _id.
As Azure Search does not allow underscores at the beginning of a field name in the index, I want to create a field mapping.
JSON structure in Cosmos --> structure in index
{
"id": "test"
"name": "test",
"productLine": {
"_id": "123", --> "id": "123"
"name": "test"
}
}
The documentation has exactly this scenario as an example but only for a top level field.
"fieldMappings" : [ { "sourceFieldName" : "_id", "targetFieldName" : "id" } ]}
I tried the following:
"fieldMappings" : [ { "sourceFieldName" : "productLine/_id", "targetFieldName" : "productLine/id" } ] }
that results in an error stating:
Value is not accepted. Valid values: "doc_id", "name", "productName".
What is the correct way to create a mapping for a target field that is a subfield?
It's not possible to directly map subfields. You can get around this by adding a Skillset with a Shaper cognitive skill to the indexer, and an output field mapping.
You will also want to attach a Cognitive Services resource to the skillset. The shaper skill doesn't get billed, but attaching a Cognitive Services resource allows you to process more than 20 documents per day.
Shaper skill
{
"#odata.type": "#Microsoft.Skills.Util.ShaperSkill",
"context": "/document",
"inputs": [
{
"name": "id",
"source": "/document/productLine/_id"
},
{
"name": "name",
"source": "/document/productLine/name"
}
],
"outputs": [
{
"name": "output",
"targetName": "renamedProductLine"
}
]
}
Indexer skillset and output field mapping
"skillsetName": <skillsetName>,
"outputFieldMappings": [
{
"sourceFieldName": "/document/renamedProductLine",
"targetFieldName": "productLine"
}
]
I am trying to write a query by performing an aggregate on one of its properties that is an array of objects. As an example in the below json structure I want the country and the biggest airport as two columns in the output
[
{
"Country": "US",
"Airports": [
{
"Name": "Kodiak Airport",
"Area": "100"
},
{
"Name": "Homer Airport",
"Area": "87"
}
]
},
{
"Country": "Mexico",
"Airports": [
{
"Name": "Gulfport-Biloxi International Airport",
"Area": "94"
},
{
"Name": "El Paso International Airport",
"Area": "68"
}
]
}
]
so the reuslt will be 2 columns, country name and biggest airport's name as below:
Country Airport
US Kodiak Airport
Mexico Gulfport-Biloxi International Airport.
The following query returns country and the first airport's name in the array airports_s.
MyLogs_CL
| project country_s, Airports = todynamic(airports_s)
| project country_s, Airports[0].name
But I don't how to perform an aggregate on that array and return the object which has the highest area among them.
I have an AQL query traversing graph that always should return a fixed amount of documents from a unique set of collections.
So each collection will occur only once and with one document only.
I wish to merge them all into a single document under properties that reflects document’s collection name.
Query as simple as:
FOR v IN ANY "vertex/key" edge_collection RETURN v
Returns a sample result as:
[
{
"_key": "123",
"_id": "foo/123",
"_rev": "_WYhh0ji---",
"foo_attribute": "lorem impsum"
},
{
"_key": "456",
"_id": "bar/456",
"_rev": "_WYhh2ny---",
"bar_attribute": "dolor sit amet"
}
]
That I wish to get like this:
[
{
"foo": {
"_key": "123",
"_id": "foo/123",
"_rev": "_WYhh0ji---",
"foo_attribute": "lorem impsum"
},
"bar": {
"_key": "456",
"_id": "calendar/bar",
"_rev": "_WYhh2ny---",
"bar_attribute": "dolor sit amet"
}
}
]
In order to get collection name from document use PARSE_IDENTIFIER function that gives document’s collection name and key separately
Use square brackets comprehension to generate document property dynamically
Simply merge result of the query
Example:
RETURN MERGE(
FOR v IN ANY "vertex/key" edge_collection
RETURN {[PARSE_IDENTIFIER(v).collection]: v}
)
Hello guys I am new to elastic search but I have gone through the basic ElasticSearch 5.1 documentation.
Problem in one line:
Search is successful but filters are not working properly.
Mapping datatypes
{
"properties": {
"title": {"type": "string"},
"description": {"type": "string"},
"slug": {"type": "string"},
"course_type": {"type": "string", "index" : "not_analyzed"},
"price": {"type": "string"},
"categories": {"type": "keyword", "index" : "not_analyzed"},
"tags": {"type" : "keyword"},
// "tags": {"type" : "keyword", "index" : "not_analyzed"},
"status": {"type" : "string","index" : "not_analyzed"},
}
}
As noted by #Darth_Vader I tried mapping as well. Following is my mapping
Document in index (Req-1)
....
{
"_index": "learnings",
"_type": "materials",
"_id": "582d9xxxxxxxx9b27fab2c",
"_score": 1,
"_source": {
"title": "Mobile Marketing",
"slug": "mobile-marketing",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eleifend hendrerit vehicula.",
"categories": [
"Digital Marketing"
],
"tags": [
"digital-marketing",
"mobile-marketing"
],
"status": "published"
}
},
...
Like above I have like hundred documents in an index
SEARCH QUERY FULL that I am using
"query": {
"bool": {
"must": {
"multi_match" : {
"query" : "mobile",
"fields" : [ "title^5", "tags^4", "categories^3" ],
"operator": "and"
}
},
"filter": {
"bool" : {
"must" : [
{"term" : {"status": "published"} }
]
}
}
}
}
In the above query the most important search criteria/filter is {"term" :
{"status": "published"} }. Every search result must meet this
requirement.
Now from the list of results, I want to filter more. So say I want to get only documents which has mobile-marketing as a tag. My document (Req-1) has this tag (mobile-marketing)
NOW the problem is:
If I modify my Search Query and add my required filter like the following below: I get NO search result (hits = 0) even though my document (Req-1) has mobile-marketing as a tag
"filter": {
"bool" : {
"must" : [
{"term" : {"status": "published"} },
{"term" : {"tags": "mobile-marketing"} }
]
}
}
BUT if I change the filter {"tags": "mobile-marketing"} TO {"tags": "mobile"}, I get the required document (Req-1) as result.
I want to get the same document using this filter: {"tags": "mobile-marketing"}. So where am I doing wrong?
What modification does my search query need?
Thanks
How does your mapping look for tags?
Seems like you've got your mapping for tags field as analyzed. What *analyzed` does is, from the books:
First analyze the string and then index it. In other words, index this
field as full text.
So it analyzes it first, where the value looks like mobile-marketing. Hence it'll store mobile and marketing separately because of the hyphen in the middle and it'll be tokenized into tokens. ie: it'll store mobile and marketing into two different tokens.
Whereas if it's not_analyzed:
Index this field, so it is searchable, but index the value exactly as
specified. Do not analyze it.
So this will basically store the value as it is without analyzing it, which should do the trick in your case. Maybe you should have a look at this point as well.
Hope it helps!