Specify a method for requesting resources by solr query?


#1

Has anyone come up with a way to specify solr query strings with RAML?

What’s the most efficient way to do that?


#2

It shouldn’t be too hard to model in RAML. Do you mean something like this example?


#3

Thanks! Sorry, I basically meant how to indicate “this resource will take a solr query string”, i.e. any solr query is valid. I will take a look to see if I can wrap my head around the example you sent. A RAML example would be great too!


#4

You can describe pretty much any kind or query parameter in RAML.

E.g.

curl 'http://localhost:8983/solr/techproducts/query?json.limit=5&json.filter="cat:electronics"' -d '
{
  query: "memory",
  limit: 10,
  filter: "inStock:true"
}'

could look something like this:

#%RAML 1.0 Library
traits:
  solrQueryable:
    queryParameters:
      json:
        properties:
          limit: integer
          filter:
            pattern: '^\w+:\w+$'


#5

@jstoiko - yes, now I get it. This is much simpler than I thought. So the solr query syntax is JSON friendly and you just need to note e.g. a JSON param for any solr-friendly methods?


#6

yes, you can model it the way you want