You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The document I'm querying is Example 2 from http://schema.org/Book.
Here's a relevant snippet:
{
"@context": "http://schema.org",
"@graph": [
{
"@id": "#author",
"@type": "Person",
"birthDate": "1892",
"deathDate": "1973",
"name": "Tolkien, J. R. R. (John Ronald Reuel)",
"sameAs": "http://viaf.org/viaf/95218067"
}]
}
Here is my query:
const doc = LD({
"@vocab": "http://schema.org/",
})(expanded)
expect(doc.query("[name=Tolkien, J. R. R. (John Ronald Reuel)]")).to.exist
This returns null, whereas I expect it to return the author's node.
Am I misunderstanding how the [@attribute=value] code is supposed to work? I'd like to be able to query on matching values within the document, not just on document structure. Is this supported?
Internally, I see your extractStep function is calling expand on step.value because it doesn't match the nonExpandableValuePropNamePattern. We end up with the value http://schema.org/Return of the King.
If I comment out the call to expand the query still fails to match, so there's something else going on as well.
The text was updated successfully, but these errors were encountered:
Sorry it's been so long getting back to you @bitmage
I believe the code doesn't cover the case you are describing, although it would be very useful.
The only current support is for testing @id, @type (?) and @Index values. General find-by-attribute functionality isn't included. Use cases I have seen usually involve doing a .queryAll to collect @type=author nodes, and then a plain-old javascript .filter or .find to pick out the one with the required attributes.
I'm considering a major overhaul of the library, in combination with a server-side version in C#, so I'm not sure whether to update the library in its current form with this functionality, or just add it to the feature list for the next version. Thoughts?
The document I'm querying is Example 2 from http://schema.org/Book.
Here's a relevant snippet:
Here is my query:
This returns null, whereas I expect it to return the author's node.
Am I misunderstanding how the
[@attribute=value]
code is supposed to work? I'd like to be able to query on matching values within the document, not just on document structure. Is this supported?Internally, I see your extractStep function is calling
expand
onstep.value
because it doesn't match thenonExpandableValuePropNamePattern
. We end up with the valuehttp://schema.org/Return of the King
.If I comment out the call to
expand
the query still fails to match, so there's something else going on as well.The text was updated successfully, but these errors were encountered: