Indexing Firebase Realtime Database - react-native

What I am trying to accomplish is accessing a single item in my database. I set up my indexing but when I query it, I get back an empty object.
Accessing it like this shows an empty object
https://yourapp.firebaseio.com/ticket.json?orderBy=%22TicketNumber%22&equalTo=2240
{
"-N6sEsiL25tQSzlNjvc4": {
"form": {
"Company": "Test",
"CompanyInvolved": "Test",
"DateCompleted": "2022-07-27T21:51:00.000Z",
"DateDepartShop": "2022-07-19T15:43:00.000Z",
"DateDepartSite": "2022-07-21T18:47:00.000Z",
"Details": "D2",
"ItemCode": "IC2",
"MoreDetails": [
[
{
"Details": "D1",
"ItemCode": "IC1",
"Quantity": "Q1"
}
]
],
"Quantity": "Q2",
"RecievedBy": "Test",
"Signature": "file:///Users/arod/Library/Developer/CoreSimulator/Devices/4498CCA0-C6F4-4E9F-BCAE-19ADB385E758/data/Containers/Data/Application/F0A9086E-A773-43C3-861F-91D3666AB627/Library/Caches/ExponentExperienceData/%2540arod1207%252FAOS/sign.png",
"ThirdParty": true,
"TicketNumber": 2240,
"TimeArriveShop": "2022-07-21T21:51:00.000Z",
"TimeArriveSite": "2022-07-19T18:47:00.000Z",
"TimeDepartShop": "2022-07-19T18:43:00.000Z",
"TimeDepartSite": "2022-07-21T18:51:00.000Z",
"TodaysDate": "2022-07-20T15:43:00.000Z"
}
},
My rules are as followed
{
"rules": {
".read": "true",
".write": "true",
"ticket": {
".indexOn": "TicketNumber"
}
}
}

Since the value you want to index lives under form/TicketNumber of each direct child node of the ticket path, that is also what you must define the index for.
So:
{
"rules": {
".read": "true",
".write": "true",
"ticket": {
".indexOn": "form/TicketNumber"
}
}
}
Same: that form/TicketNumber is also the path you need to specify for the orderBy parameter of your query.

Related

Can't make PUT /raylight/v1/documents/id/parameter/id work properly

I need to update document parameters via REST API.
I've tried using the following:
PUT .../raylight/v1/documents/33903/parameters/3
with the following json payload
{
"parameters":{
"parameter": {
"id": 3,
"answer": {
"values": {
"value": [
"2019/9"
]
}
}
}
}
}
But the returned answer shows unmodified parameters:
{
"parameter": {
"#optional": "false",
"#type": "prompt",
...
"id": 3,
...
"answer": {
...
"info": {
...
"previous": {
"value": [
"2015\/12"
]
}
},
"values": {
"value": [
"2015\/12"
]
}
}
}
}
How can I properly set new prompt parameters?
Do:
PUT .../raylight/v1/documents/33903/parameters
instead of:
PUT .../raylight/v1/documents/33903/parameters/3
Adding a parameter ID at the end performs a different function: it returns the list of parameters that are dependent upon the one provided. You have only one in this case, and it's returning itself. Leave it off, to refresh the document.

How to filter on field inside array of references using Sanity GROQ?

Given this result from Sanity vision, how can I correctly filter out the shows array to only return shows that are active === true?
{
"result": {
"_createdAt": "",
"_id": "xyz",
"_rev": "abc",
"_type": "content",
"active": true,
"content": {
"_key": "47d6e74f1f81",
"_type": "radio",
"shows": [ <-- Reference of `radioShow`
{
"active": true
},
{
"active": false
}
]
},
}
}
Here is my groq query. How do I add a filter to the shows array?
*[_type == "content"
&& active == true
&& content[0]._type == "radio"
] {
...,
"content": content[0] {
...,
shows[]-> { <-- How do I had a filter here?
active,
}
}
}[0]

Apache Nifi: UpdateRecord replace child values

I'm trying to use UpdateRecord 1.9.0 processor to modify a JSON but it does not replace the values as I want.
this is the source message
{
"type": "A",
"ids": [{
"id": "1",
"value": "abc"
}, {
"id": "2",
"value": "def"
}, {
"id": "3",
"value": "ghi"
}
]
}
and the wanted output
{
"ids": [{
"userId": "1",
}, {
"userId": "2",
}, {
"userId": "3",
}
]
}
I have configured the processor as follows
processor config
Reader:
reader
Schema registry:
schema
writer:
writer
And it works, the output is a JSON without the field 'type' and the ids have the field 'userId' instead 'id' and 'value'.
To fill the value of userId, I defined the replace strategy and the property to replace:
strategy
But the output is wrong. The userId is always filled with the id of the last element in the array:
{
"ids": [{
"userId": "3"
}, {
"userId": "3"
}, {
"userId": "3"
}
]
}
I think the value of the expression is ok because if I try to replace only one record it works fine (/ids[0]/userId, ..id)
Nifi docs has a really similar example (example 3):
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.7.1/org.apache.nifi.processors.standard.UpdateRecord/additionalDetails.html
But it does not work for me.
What am I doing wrong?
thanks
Finally I have used JoltJSONTransform processor instead UpdateRecord
JoltJSONTransform
template:
[
{
"operation": "shift",
"spec": {
"ids":{
"*":{
"id": "ids[&1].userId"
}
}
}
}
]
Easier than UpdateRecord

Avro allow blank JSON/hash for nested attributes

Need to Create Avro schema for this ->
{"city":"XXXXXX", "brand":"YYYY", "discount": {} }
{"city":"XXXXXX", "brand":"YYYY", "discount": {"name": "Freedom", "value": 100} }
{"city":"XXXXXX", "brand":"YYYY", "discount": {"name": "Festive Sale", "value": 100} }
I tried with the below shemas, which do not work:
{ "type":"record", "name":"simple_avro",
"fields":[ { "name":"city", "type":"string" },
{ "name":"brand", "type":"string" },
{ "name":"discount",
"type":{ "type":"record", "name":"discount", "default":"",
"fields":[ { "name":"discount_name", "type":"string", "default":"null" },
{ "name":"discount_value", "type":"float", "default":0 }
] }}
] }
For discount field, I have tried default to as "[]", "{}", "", but none of these work.
I don't think an empty {} object is allowed in any case, but if you want to allow no object at all, then it needs to be a union type, as designated by an array for the type, the the default value goes on the outer field rather than inside the record body
{ "name":"discount",
"type" : [
"null",
{ "type":"record", "name":"discount", "fields": [...] }
],
"default" : "null"
In general, I find that easier to express in IDL format
Then, a valid message could be {"city":"XXXXXX", "brand":"YYYY"}

Elastic Search Query for displaying the documents when it contains all the set of specific properties

I am new to Elastic Search APIs. I have a requirement where i need to query and list the documents which compulsorily contains following properties, say
"request: "/v3?id=100000" & "type: "GET"
Result should contains list of documents containing both the above. I have tried the following and it gets either of the above.
{
"query": {
"match": {
"type": "GET"
}
}
}
I tried
{
"query": {
"match": {
"type": "GET",
"request: "/v3/id=100000"
}
}
}
It fails...
Can someone suggest me a query to list all the docs with both the properties set as above ? Not sure how to use filters, if I try it shows failures - parse exceptions.
My example document:
{
"_index": "logstash-2016.04.22",
"_type": "endpoint-access",
"_id": "fAhTQkDRQTiHKlzuleNA",
"_score": null,
"_source": {
"#version": "1",
"#timestamp": "2016-04-22T15:26:35.153Z",
"offset": "43714176",
"ident": "-",
"auth": "-",
"timestamp": "22/Apr/2016:15:26:35 +0000",
"type": "GET",
"request": "/v3?id=1b32e833-b521",
"httpversion": "1.1",
"response": "500",
"bytes": "265",
"referrer": "-",
"agent": "-",
"x_forwarded_for": "\"101.2.123.24\""
"host": "101.123.115.167"
},
"sort": [
1461338795153,
1461338795153
]
}
You may use "must" to get the result:
{
"query": {
"bool": {
"must": [
{
"match": {
"type": "GET"
}
},
{
"match": {
"request": "/v3/id=100000"
}
}
]
}
}
}