I'm not quite sure exactly what you're looking to do but I think you can do what you're looking for is bindings. I don't think that the stored queries url is quite qhe you sent but you can execute a stored query through the normal query interface but just give the name instead of the "select * where...." and then pass some initial bindings. I don't think the final url will be very pretty though.
This functionality already exists, though I will admit it's not documented very well at the moment. Just a couple of gotchas:
Your stored query should have variables that start with a $ instead of a ? so the ?s don't get caught up in the URL parser
The query string parameters should also have the $
Example:
Query: select $s $p { $s a :Thing; $p $o }
URL: http://myStardog:5820/myDb/query?query=myStoredQuery&$s=<some:uri> (well actually it'd be ...?query=myStoredQuery&%24s%3D%3Csome%3Auri%3E, but I went for readability)
Thanks for this info, great to hear that this is already implemented! And yes, I was a little lazy with the syntax in my post, Stephen's post clarified that though.
I think I still have an issue, however. Does this only work with a URI or could it work with a string?
The value needs to be a syntactically valid constant term. Stepping back for a second, the value will be substituted for a variable in your query. However, '$search' is not a variable, it is a string constant. You need to remove the quoting, ie $search. That said, it should now make sense that the bound value will be substituted for that variable. The bound value can be a string, such as 'foo' (note the quotes), an IRI <tag:stardog:...>, etc. So you need to remove the quotes around '$search' and add them around foo.
Not sure I follow, $string is not a SPARQL variable, but ?search would be. I thought using the $ denoted a special template keyword that was just replaced by the parameter passed through in the URL.
However, I did try what you suggested. When I go to save this query in Studio I get the following:
It looks like the bug is creating a stored query with the textMatch property function using a variable for the search query. I'll create a new ticket for this. This query is not valid in general without a bound value.
In the interim, you can still accomplish the same thing without a stored query:
@stephen, woa thanks for pointing that out... I have always seen SPARQL variables written with a question mark, had no idea that is in the spec and a dollar symbol can be used.
For these template queries, is there any difference between using the ? or $ when constructing a URL to execute the query? It seems like including the variable prefix symbol could be omitted, similar to how in the CLI the binding just uses the variable name search, not $search: stardog query explain db -b search='"food"'
@Jess thanks for filing a ticket. I think this would be pretty handy to have work.