Closed ckristo closed 7 years ago
I can get you pretty close:
client.select(:country, :population)
.where([ :country, RDF.type, DBP_ONT.Country ])
.where([ :country, DBP_PROP.populationCensus, :population ])
.filter('isNumeric(?population) && ?population > 50000000 ')
.order_by(:country)
To my knowledge, we have no DSL support for DESC
or for constructing filters.
The filters seem like a fairly substantial work chunk, and maybe wouldn't present any usability over just expecting the user to input a filter string.
DESC
/ASC
might be more manageable, though.
ping: @gkellogg, @bendiken
DESCRIBE/ASC definitely easy to do. We also need some better uodate DSL.
@gkellogg How can I specify the DESC
part of an ORDER BY
clause with SPARQL::Client::Query
's .order_by
method? I didn't get it, sorry..
@no-reply Thanks for your input / your help! :-)
EDIT: After looking at the relevant code in query.rb, I found out how to specify it; you can simply use a string instead of a symbol -- the complete example:
query = client.select(:country, :population)
.where([ :country, RDF.type, DBP_ONT.Country ])
.where([ :country, DBP_PROP.populationCensus, :population ])
.filter('isNumeric(?population) && ?population > 50000000')
.order_by('DESC(?population)')
.limit(5)
It would be nice if there's a way to specify the DESC part as symbol though, e.g.
query.order_by([ [:var1, :desc], [ :var2, :asc ], :var3, ... ]) # :var3 = [ :var, :asc ]
EDIT2: It seems that something similar was planned when looking at query_spec.rb
For filter()
, I agree with @no-reply. Nevertheless, it would be really nice to have a DSL for the FILTER
part as well (for a coherent API).
That's a feature that needs to be added. I'll get around to looking at it soon.
Created a PR that adds support for specifying the sort order direction with .order()
:: #61
Hi,
I want to demonstrate the functionality of
sparql-client
s querying API; therefore I want to translate the following query string into API calls:=>
but I just don't know how to "translate" the
FILTER
and theORDER BY
DESC
parts. Anyone done that and can support me here?