GraphQL query for ContentTagSets

36 views
Skip to first unread message

Rob Atkinson

unread,
Jul 2, 2020, 3:15:48 AM7/2/20
to TopBraid Suite Users

After some fiddling I can return data from a content tag set 

with a query like this

{
  clauseSections(where: {rdfs_label: {pattern: "def"} 
  } ) {
    rdfs_label
    topic {
      label
    }
    uri
  }
}

This successfully returns details from the linked topic.

But I cant get a query to work the restricts the subjects by properties of the topics. I cant find examples of syntax for:

1) filtering main object on properties of nested objects
2) filtering if a value is present ( _is_null) 
3) combining (AND and OR) filters 

Also, I created property shapes for the subject root class and tagging property in order to make this work to retrieve details of , but perhaps there is some way of making this happen (I created and ran SHACL rules to enforce this.. so its repeatable - but have I duplicated something?)







Holger Knublauch

unread,
Jul 2, 2020, 3:24:02 AM7/2/20
to topbrai...@googlegroups.com


On 2/07/2020 17:15, Rob Atkinson wrote:

After some fiddling I can return data from a content tag set 

with a query like this

{
  clauseSections(where: {rdfs_label: {pattern: "def"} 
  } ) {
    rdfs_label
    topic {
      label
    }
    uri
  }
}

This successfully returns details from the linked topic.

But I cant get a query to work the restricts the subjects by properties of the topics. I cant find examples of syntax for:

The fallback for any type of filter is SPARQL:

https://www.topquadrant.com/graphql/graphql-queries.html#sparql

Did you try that?


1) filtering main object on properties of nested objects
2) filtering if a value is present ( _is_null)

To check for non-existence of a property, you can probably use maxCount 0

{
  concepts(where: {
    hidden: {
        maxCount: 0
      }}) {
    uri
  }
}

3) combining (AND and OR) filters
Use SPARQL for that. GraphQL isn't meant as a complete replacement without "help" - its benefit is simplicity for the average web developer.


Also, I created property shapes for the subject root class and tagging property in order to make this work to retrieve details of , but perhaps there is some way of making this happen (I created and ran SHACL rules to enforce this.. so its repeatable - but have I duplicated something?)

Sounds good. The GraphQL engine is based on the presence of SHACL definitions, so if no such property shapes exist, the engine will not offer GraphQL fields.

Holger









--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/deda2c9b-08c1-4d51-8dfa-cde898e02c04n%40googlegroups.com.

Rob Atkinson

unread,
Jul 2, 2020, 3:32:50 AM7/2/20
to TopBraid Suite Users
 
{
  clauseSections(where: {
    topic: { 
      exists: {
        label: {pattern: "ID4"}
      }
    }
  }) {
    rdfs_label
    topic {
      label
    }
    uri
  }
}

=> 

{
  "errors": [
    {
      "message": "Validation error of type WrongType: argument 'where.topic' with value 'ObjectValue{objectFields=[ObjectField{name='topic', value=ObjectValue{objectFields=[ObjectField{name='exists', value=ObjectValue{objectFields=[ObjectField{name='label', value=ObjectValue{objectFields=[ObjectField{name='pattern', value=StringValue{value='ID4'}}]}}]}}]}}]}' contains a field not in 'ClauseSection_where_topic': 'exists'",
      "locations": [
        {
          "line": 2,
          "column": 18
        }
      ]
    }
  ]
}





Holger Knublauch

unread,
Jul 2, 2020, 3:53:43 AM7/2/20
to topbrai...@googlegroups.com

Is topic an object property shape or a literal-valued one? (Can you show the shape declarations).

Holger

Rob Atkinson

unread,
Jul 14, 2020, 1:18:28 AM7/14/20
to TopBraid Suite Users

Sorry didnt get back to this..

the shape declaration looks like:

ex:MyClass-pshape
  a sh:PropertyShape ;
  sh:class skos:Concept ;
  sh:description "Concept used to tag objects in this document" ;
  sh:nodeKind sh:IRI ;
.


the other thing that happens is that if you add topic to the search results display as an extra column it is blank - and inspection of the network traffic shows the underlying graphql query is returning topic:[] incorrectly for everything.

Simon Opper

unread,
Jul 14, 2020, 5:41:56 PM7/14/20
to topbrai...@googlegroups.com
Hi Holger

A simple use case of viewing corpus topics is if the tagset is imported into a datagraph. How are the values of the content and corresponding tag shown on a form.

E.g.  
Content1 corpus:topic conceptA
Content 1 corpus:topic conceptB


For example, if I have a form in the datagraph that references the URL of Content1. How can the above corpus:topic triples be used to generate an inference in a form to list all existing tags for Concent1 (e.g. content A and B) ?

The only way I've been able to do this is to construct new instances of a class with new properties

e.g. something like

Content1 a corpus:Document ;
corpus:hasTopic Content A ;
corpus:hasTopic Content B .

But this just leads to a lot of information bloat.

On the fly inferences are preferred.

Cheers mate

Simon





Irene Polikoff

unread,
Jul 14, 2020, 7:11:25 PM7/14/20
to topbrai...@googlegroups.com
I am confused. Do you have conceptA and Content A or is it a typo?

If ContentA is a corpus:Document, you should see corpus:topic values on its form.

Simon Opper

unread,
Jul 14, 2020, 7:38:26 PM7/14/20
to topbrai...@googlegroups.com
Hi Irene

Yes, my mistake, it was too early before caffeine

it should be

For example, if I have a form in the datagraph that references the URL of Content1. How can the above corpus:topic triples be used to generate an inference in a form to list all existing tags for Content1 (e.g. Concept A and B) ?

e.g. something like

Content1 a corpus:Document ;
corpus:hasTopic Concept A ;
corpus:hasTopic Concept B .

Many thanks

Simon



Irene Polikoff

unread,
Jul 14, 2020, 7:51:24 PM7/14/20
to topbrai...@googlegroups.com
Hi Simon,

Are you saying that:

  • You have a data graph with some information about :Content1
  • You included into it a content tagset that contains the following triples

:Content1 corpus:topic conceptA
:Content 1 corpus:topic conceptB

  • When you click on :Content1 in your data graph, you are not seeing the above triples on a form

If this is correct, what is the type of :Content1? 

I am assuming that it has corpus:Document type (directly or transitively). If it is the case, then you should see these properties on the form. If it has multiple types, you would see a drop down on the form (upper right corner), that will let you switch between different views. You will see the tag values only if you pick the Document.

Here is an example of something similar - for a data element which has two types:


As you switch between views, you may see different data.

In 6.4, there is a new Setting option on the form that will present a merged view.


Rob Atkinson

unread,
Jul 14, 2020, 8:25:28 PM7/14/20
to TopBraid Suite Users

Might weigh in here to separate some concerns:

1) When using a ContentTagSet ( linking a DataGraph to a Taxonomy - via corpus:topic ) there are two apparent problems that may be the same in fact:
 a ) adding "topic" to the search result columns doesnt show values for topics - even though individual items show topics in both the form view and the tagging panel, and GraphQL queries return topic values OK.
b) Cannot find a means to filter on topic in the GraphQL

2) We cannot find a natural way in the (new) editor to simply find all things with a given tag, or browse tags that are actually present - manually adding the topic column every time you view the asset column is a sub-optimal option anyway - are we missing something here?

3) If the topic column approach does make sense and can be made to work - how can we persist it (and automatically configure it when generating a TagSet programatically)

4) Simon is playing with treating the ContentTagSet as a DataGraph in order to see if it behaves differently - but its another sub-optimal workaround for searching and browsing applied tags.  (I dont think inferencing is required the content is the same as in the tagset)

5) when adding another column its display widget choice might need to be set - if we have a multivalued object property whose values are blank nodes it gives ugly node identiers - even though   dash:viewer =  dash:DetailsViewer  and this content works fine on a form - maybe there is some other property/viewer thing that controls this we can use?

Simon Opper

unread,
Jul 14, 2020, 8:28:13 PM7/14/20
to topbrai...@googlegroups.com
Hi Irene

Are you saying that:

  • You have a data graph with some information about :Content1  
Yes

  • You included into it a content tagset that contains the following triples
Yes
:Content1 corpus:topic conceptA
:Content 1 corpus:topic conceptB
Yes
  • When you click on :Content1 in your data graph, you are not seeing the above triples on a form
Correct, I'm not seeing the the values. I may want to show the value of Content1 or ConceptA depending on the nature of the form e.g. ingoing or outgoing reference.

If this is correct, what is the type of :Content1? 

The type of Content1 is an instance of a class



I am assuming that it has corpus:Document type (directly or transitively). If it is the case, then you should see these properties on the form. If it has multiple types, you would see a drop down on the form (upper right corner), that will let you switch between different views. You will see the tag values only if you pick the Document.

No, this is my point.  When a tagset is created in edg only the followoing triples are generated in the graph


there is no instance of a corpus:Document instantiated.

There is something that forms cannot surface about the relationship 

Here is an example of something similar - for a data element which has two types:

Please can you try to make only corpus:topics work.  I'm aware of the selection of different properties for forms and it doesn't work for corpus:topics

Many thanks

Simon

Irene Polikoff

unread,
Jul 14, 2020, 9:10:07 PM7/14/20
to topbrai...@googlegroups.com
Please see below

On Jul 14, 2020, at 8:25 PM, Rob Atkinson <rob.at...@surroundaustralia.com> wrote:


Might weigh in here to separate some concerns:

1) When using a ContentTagSet ( linking a DataGraph to a Taxonomy - via corpus:topic ) there are two apparent problems that may be the same in fact:
 a ) adding "topic" to the search result columns doesnt show values for topics - even though individual items show topics in both the form view and the tagging panel, and GraphQL queries return topic values OK.
b) Cannot find a means to filter on topic in the GraphQL

May be you can send a small example to reproduce? I do not know exactly how your model and your data looks like. If you can filter in GraphQL, the search results column should work - unless there is some bug.


2) We cannot find a natural way in the (new) editor to simply find all things with a given tag, or browse tags that are actually present - manually adding the topic column every time you view the asset column is a sub-optimal option anyway - are we missing something here?

And if you save the search view with this column as default, it does not work?

I think I will be able to answer your questions better once I see an example.

In the meantime, we have a legacy example of Content Tagset with Paintings (in the samples project) that uses as tags a property that is not declared for the shape of resources being tagged. It also uses a Data Graph asset collection as the content graph.

In this case, I don’t believe one could get these values in GraphQL or in Search. I think this particular example has issues (lack of complete schema) - as I said, it came from some legacy content. 

I think if the tag property was declared in the shape for these resources, we would see it on a form and be able to navigate to it easily. Then, if inverse shape was declared for the tags (concepts), you would see right on the concept’s form items tagged with it.

In the absence of this, one way to find all items tagged with a given concept would be as follows:

1. Select Navigate to Asset by Label from the “more” menu in the header



2. In the dialog that will appear type a label to select a concept e.g., war

3. Then use References panel to find everything tagged with it


This will work generically - irrespective of the property used.

To find all concepts that have been assigned as tags, I would probably use a query - it could be saved to a library for people who are not comfortable with SPARQL. In this particular case we are using dc:subject as the tag property.


In 6.4, you could also create a parametrized query for users to find all assets tagged with a given tag. Replace ?concept with $concept. Then save the query.


Then, select this query from the library and run it


You get the following result



Irene Polikoff

unread,
Jul 14, 2020, 9:15:34 PM7/14/20
to topbrai...@googlegroups.com
I think you need to have a shape to declare that corpus:topic is a property of metanorma:ClauseSection

This could be done for the metanorma:ClauseSection or some parent class - I am sure you know this.

The form will only display property values for which a property shape exist - I suspect you know this as well.

If this does not help, send me a small example off the list.

> On Jul 14, 2020, at 8:27 PM, Simon Opper <simon...@surroundaustralia.com> wrote:
>
> Hi Irene
>
> <PastedGraphic-2.png>
> To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/CABfSiRNd%2B-BSaxxnjEPczLWc%2BFK6wkuuVMzU1LiOjNEnahPU1Q%40mail.gmail.com.

Rob Atkinson

unread,
Jul 14, 2020, 10:53:04 PM7/14/20
to TopBraid Suite Users

solved: form makes up a label for topic - it was in fact missing labels for topics due to a namespace change that didnt get propagated to the tagset properly.   

Lesson - never have labels that match what the system will generate if missing 

Rob Atkinson

unread,
Jul 14, 2020, 11:18:04 PM7/14/20
to TopBraid Suite Users
spoke too soon - here is an example showing the shape, the existence of labels, and the failure to show the label in the Tag search form.
in addition, filter on  topic doesnt work here either.

(in other news... on a tagset editor its not obvious how to save the default layout - and the question is still how to achieve this result without using the UI - what metadata needs to go where? )



Rob Atkinson

unread,
Jul 15, 2020, 12:34:09 AM7/15/20
to TopBraid Suite Users
sorry gmail seems to have killed that screenshot .. grrr
Reply all
Reply to author
Forward
0 new messages