ld-query
ld-query copied to clipboard
[@attribute=value] does not appear to work with regular strings as value
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.