ld-query icon indicating copy to clipboard operation
ld-query copied to clipboard

[@attribute=value] does not appear to work with regular strings as value

Open bitmage opened this issue 6 years ago • 2 comments

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.

bitmage avatar Apr 23 '18 19:04 bitmage