Sparql GROUP_CONCAT returns empty json tag for empty results.

8 views
Skip to first unread message

akshay.des...@gmail.com

unread,
Sep 15, 2016, 2:31:42 AM9/15/16
to Stardog
Hi,
I have the below sparql query

select distinct ?isbn ?bookTitle ?subTitle ?seriesTitle ?seriesSubCategory ?copyrightYear (GROUP_CONCAT(?editorName; SEPARATOR = ",") AS ?editorNames) where
{


{
 
select distinct ?pointer where {
 
?bookProfile a smt:BookProfile.
 
?pointer smt:compiledIn ?bookProfile;
       smt
:searchLabel ?searchLabel.
   filter regex
(?searchLabel, "[.]*benzene[.]*", "i")
 
}
  offset
0
  limit
20
}


 
?pointer smt:electronicISBN ?isbn;
       smt
:title ?bookTitle;
       smt
:subTitle ?subTitle;
       smt
:seriesTitle ?seriesTitle;
       smt
:seriesSubCategory ?seriesSubCategory;
       smt
:copyrightHolderName ?copyrightHolderName;
       smt
:copyrightYear ?copyrightYear;
       smt
:editor ?editor.


 
?editor smt:name ?editorName.




}
group by ?isbn ?bookTitle ?subTitle ?seriesTitle ?seriesSubCategory ?copyrightYear ?editorNames

and below is the resulting json from this query 


{
 
"head" : {
   
"vars" : [
     
"isbn",
     
"bookTitle",
     
"subTitle",
     
"seriesTitle",
     
"seriesSubCategory",
     
"copyrightYear",
     
"editorNames"
   
]
 
},
 
"results" : {
   
"bindings" : [
     
{
       
"editorNames" : {
         
"type" : "literal",
         
"value" : ""
       
}
     
}
   
]
 
}
}

I don't want the empty json tag if the result is empty.
How can i handle this at the query level ?

Thanks,
Akshay

Evren Sirin

unread,
Sep 16, 2016, 12:03:54 PM9/16/16
to Stardog
You can add a filter at the end to eliminate such results:

HAVING (?editorNames) != "")

Best,
Evren
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com
> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
Reply all
Reply to author
Forward
0 new messages