How can I use cursors to paginate field-expanded queries? - facebook

I can do this:
/<post_id>/comments?filter=stream&limit=100&after=<cursor>
But this doesn't work:
/<post_id>?fields=comments.filter(stream).limit(100).after(<cursor>)
Am I missing something in the syntax? Though cursor-based paging and field expansion were launched a the same time, their respective docs don't reflect each other.

Just figured this out (I think).
Most cursors have an = (equals sign) appended to them. For example: MzA=
This causes this syntax error in field expansion:
Syntax error "Expected ")" instead of '".' at character 79: comments.filter(stream).limit(10).summary(true).fields(id,like_count).after(NDA"
However, stripping the trailing = resolves the syntax error and results seem to paginate as expected.

Related

Regex to match anything between = object and (

I'm developing a VS Code extension to support a new language, and for some syntax highlight I want to match any text between = object and (.
I tried the following Regex:
{
"name": "entity.name.class",
"match": "(?<==\\s*object).*?(?=\\()"
},
But when I add this to my grammar file it breaks all the other rules that were working, everything turns white again.
That Regex (?<==\s*object).*?(?=\()/g works on https://regexr.com/ with the following text:
!var = object REAL()
!var = object BORE(!bore)
!var =object REAL ()
!var =object BORE (!bore)
VS Code doesn't give me any exception or hint why this Regex is not working, does anyone have a clue on why the Regex is not working in VS Code?
You mention that adding your new pattern causes your test file to lose all syntax highlighting. This leads me to believe that you have a syntax issue within the actual grammar that's preventing any syntax pattern application. Your regular expression, while not optimal, seems to be syntactically correct, so I doubt that's the cause of your problem. For future reference, VS Code only applies syntax pattern matching one line at a time. This means that if your regex was incorrect, only the lines that match the pattern would lack the syntax highlighting, rather than the whole document.
Hopefully this answer isn't too late for your problem.

How to make query to collection from MongoDb functions? [duplicate]

I have a collection I'm unable to drop, I'm assuming that the "-" in its name is a special character. In MongoDB, what is the best way to escape special characters?
> db.tweets.drop();
true
BUT
> db.tweets-old.drop();
ReferenceError: old is not defined (shell):1
I've tried to escape with quotes (both single and double) and a slash, but nothing works.
The following works:
db["tweets-old"].drop();
It's called the square bracket notation, which allows you to use special characters in property names.
So does:
db.getCollection("tweets-old").drop()
And that has been around for a while now.
In addition, the method call also mimics what is the general "get a collection" accessor method in all officially supported MongoDB drivers. So the suggestion here is that you get used to using it this way, since the "named collection" accessor is how it is generally done.

Algolia tag not searchable when ending with special characters

I'm coming across a strange situation where I cannot search on string tags that end with a special character. So far I've tried ) and ].
For example, given a Fruit index with a record with a tag apple (red), if you query (using the JS library) with tagFilters: "apple (red)", no results will be returned even if there are records with this tag.
However, if you change the tag to apple (red (not ending with a special character), results will be returned.
Is this a known issue? Is there a way to get around this?
EDIT
I saw this FAQ on special characters. However, it seems as though even if I set () as separator characters to index that only effects the direct attriubtes that are searchable, not the tag. is this correct? can I change the separator characters to index on tags?
You should try using the array syntax for your tags:
tagFilters: ["apple (red)"]
The reason it is currently failing is because of the syntax of tagFilters. When you pass a string, it tries to parse it using a special syntax, documented here, where commas mean "AND" and parentheses delimit an "OR" group.
By the way, tagFilters is now deprecated for a much clearer syntax available with the filters parameter. For your specific example, you'd use it this way:
filters: '_tags:"apple (red)"'

Mongodb how to access collection which includes special characters i.e. -,?,%? [duplicate]

I have a collection I'm unable to drop, I'm assuming that the "-" in its name is a special character. In MongoDB, what is the best way to escape special characters?
> db.tweets.drop();
true
BUT
> db.tweets-old.drop();
ReferenceError: old is not defined (shell):1
I've tried to escape with quotes (both single and double) and a slash, but nothing works.
The following works:
db["tweets-old"].drop();
It's called the square bracket notation, which allows you to use special characters in property names.
So does:
db.getCollection("tweets-old").drop()
And that has been around for a while now.
In addition, the method call also mimics what is the general "get a collection" accessor method in all officially supported MongoDB drivers. So the suggestion here is that you get used to using it this way, since the "named collection" accessor is how it is generally done.

Working with special characters in a Mongo collection

I have a collection I'm unable to drop, I'm assuming that the "-" in its name is a special character. In MongoDB, what is the best way to escape special characters?
> db.tweets.drop();
true
BUT
> db.tweets-old.drop();
ReferenceError: old is not defined (shell):1
I've tried to escape with quotes (both single and double) and a slash, but nothing works.
The following works:
db["tweets-old"].drop();
It's called the square bracket notation, which allows you to use special characters in property names.
So does:
db.getCollection("tweets-old").drop()
And that has been around for a while now.
In addition, the method call also mimics what is the general "get a collection" accessor method in all officially supported MongoDB drivers. So the suggestion here is that you get used to using it this way, since the "named collection" accessor is how it is generally done.