Aggregation with $and not working in rmongodb - aggregation

I have a very simple stage in an aggregation pipe that causes me trouble. The following works as expected in the shell:
db.People.aggregate(
{$match: {$and: [ {"Name": "B^M"},
{"ID": "0006221671"} ] } }
)
However, I tried to run the same with rmongodb and get back error(10):
query <- '{"$match": {"$and": [ {"Name": "B^M"},
{"ID": "0006221671"} ] }}'
cmd <- list(mongo.bson.from.JSON(query))
mongo.aggregation(db, collection, cmd))
Can anybody give me a hint why this does not work? Any help is greatly appreciated!

please check this rmongodb issue for more details: https://github.com/mongosoup/rmongodb/issues/17

Try to construct bson from list as described in github thread. In latest version it should work fine. You can install it directly from gihub:
library(devtools)
install_github('mongosoup/rmongodb')

Related

Elasticsearch-Py Bulk Helper expected field [create], [delete], [index] or [update] but found [_op_type]'

I'm currently trying to bulk index a bunch of documents to a data stream in elastic using Python and I'm getting strange errors.
Here is my code:
for event in raw:
tmp = {
"#timestamp": event['timestamp'],
"event" : {"kwh": event['kwh']},
"location": f"{self.args.location}",
"sourcetype": "meterdata",
"host.name": f"{self.args.name}"
}
payload={
"_op_type": "create",
"_index": "energiemonitoring",
"_source": tmp
}
payloadlist.append(payload.copy())
payload=json.loads(json.dumps(payloadlist,default=self.make_json_serial))
r = helpers.bulk(
self.es_client,
payload,
raise_on_error=False
)
Which is following the documentation provided by Elastic here.
Sadly I get the following error:
elasticsearch.BadRequestError: BadRequestError(400, 'illegal_argument_exception', 'Malformed action/metadata line [1], expected field [create], [delete], [index] or [update] but found [_op_type]'
Replacing the _op_type with create is not helping either:
Code:
payload={
"create": tmp,
"_index": "energiemonitoring",
}
Error:
elasticsearch.BadRequestError: BadRequestError(400, 'illegal_argument_exception', 'Action/metadata line [1] contains an unknown parameter [#timestamp]'
My Elastic version is 8.5.3
Has someone experienced a similar issue before?
Thank in advance!
The serialization messed up the request. Thanks again for the help

Basic JSON - issue with the bloody bracket

For a while now I've been trying to add Airtouch to HOmebridge and failing miserably.
Current attempt
The original code is this
"platforms": [
{
"platform": "Airtouch",
"name": "Airtouch",
"ip_address": "192.168.0.10",
"ac_include_temps": false,
"units": [
{
"manufacturer": "LG",
"model": "B36AWY-7G6",
"fan": ["AUTO", "QUIET", "LOW", "MEDIUM"]
}
]
}
]
What am I missing? Happy to find someone to be able to troubleshoot & fix :)
Validation error:
Validation error
Thank you all, #user1239299 for sticking around, and #alexanderdavide for sharing the validator tool
I believe I figured out what the error was
I would love to know how to make it perfectly line up though:
enter image description here
At the moment it looks ugly. And when I move the lines of code to match the first picture, and upon saving the config, I get this. The last two brackets caused the issue :) :
enter image description here
The square brackets do align with each other

Issue parsing XLIFF with node XML parser

Im trying to parse XLIFF file using xml2js library. All is working fine but if I have something like that: <source>Welcome to <x id="INTERPOLATION" equiv-text="{{ title }}"/> my friend</source> I will get [{"_":"Welcome to my friend","x":[{"$":{"id":"INTERPOLATION","equiv-text":"{{ title }}"}}]}]. I am basically loosing order for the parts of the sentence. I would expect to get an array of 3 parts:
"Welcome to "
[{"$":{"id":"INTERPOLATION","equiv-text":"{{ title }}"}}]
" my friend"
But instead Im getting:
"Welcome to my friend"
[{"$":{"id":"INTERPOLATION","equiv-text":"{{ title }}"}}]
If I would try to recreate string again I would get <source>Welcome to my friend<x id="INTERPOLATION" equiv-text="{{ title }}"/></source>
Any idea how to solve it with this XML parser or any other?
you also might like txml. When using it like txml.parse(yourXMLString), you get an object like this:
[
{
"tagName": "source",
"attributes": {},
"children": [
"Welcome to ",
{
"tagName": "x",
"attributes": {
"id": "INTERPOLATION",
"equiv-text": "{{ title }}"
},
"children": []
},
" my friend"
]
}
]
I think it looks absolutely as what you are looking for. The three children inside the source, are very clean to use. Also, this parser is only 4kb in size and there is no need for native c compiling that will cause difficulties when running your app on a different architecture.
Disclaimer: I am the author of txml, and this opinion might not be objective ;-)
With fast-xml-parser.
Please, use stopNodes in options when you parse the source.
It makes fast-xml to treat the content as plain-strings
var parser = require("fast-xml-parser");
parser.parse(srcFile, {ignoreAttributes: false, stopNodes: ["source", "target"],});

item ID name or ID inside item in json structure of couchDB, best performance?

The documentation of couchDB seem to only have examples of the format (leaving out parentheses here):
[
{id: xyz, content: jfdsh},
{id: abc, content: lkjfd}
...
]
I want to use the following format:
[
xyz: {content: jfdsh},
abc: {content: lkjfd}
...
]
No example in the docs uses this. 1) does this work and 2) is it performant? Firebase seems to opt for the latter for performance. But there are reasons to prefer couchDB...
Grateful for insights!
For CouchDB, use documents in json format like this:
{
"_id": "my_doc",
"number": 23
}

get author from Confluence CQL Search String Version 3

How is it possible to get the author (from pages, comments, etc) for the search results with the Confluence CQL API Version 3.0?
For my search the API search Version 3.0 is necessary
This one gaves no Content snippet back:
https://myconfluence.site/rest/searchv3/1.0/search?queryString=SEARCHTEXT&startIndex=0&where=conf_all
The function "&expand=body.storage" doesn't work for me.
The only results i get are:
id,
title,
bodyTextHighlights,
url,
searchResultContainer
--name
--url
friendlyDate,
contentType,
metadata,
Anybody an idea? Thanks a lot.
I tried another search API to get the page creator and this works for me.
Instead of body.storage, you can expand history to get the creator of a page.
The rest call
/rest/api/content/search?cql=id=<pageId>&expand=history
leads to an output like this and you can walk through till the creator
{
"results": [{
"id": "123456",
...
"history": {
"latest": true,
"createdBy": {
...
"username": "Some.Name",
"displayName": "Some Name",
"userKey": "123456"
}
}
...
}

Resources