You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Mike Thomsen <mi...@gmail.com> on 2016/02/24 14:48:50 UTC
/select changes between 4 and 5
With 4.10, we used to post JSON like this example (part of it is Python) to
/select:
{
"q": "LONG_QUERY_HERE",
"fq": fq,
"fl": ["id", "title", "date_of_information", "link", "search_text"],
"rows": 100,
"wt": "json",
"indent": "true",
"_": int(time.time())
}
We just upgraded to 5.4.1, and now we can't seem to POST anything to
/select. I tried it out in the admin tool, and it only does GET operations
against /select (tried changing it to POST and moving query string to the
body with Firefox dev tools, but that failed).
Is there a way to keep doing something like what we were doing or do we
need to limit ourselves to GETs? I think our queries are all small enough
now for that, but it would helpful to know for planning.
Thanks,
Mike
Re: /select changes between 4 and 5
Posted by Yonik Seeley <ys...@gmail.com>.
On Wed, Feb 24, 2016 at 12:51 PM, Shawn Heisey <ap...@elyograg.org> wrote:
> On 2/24/2016 9:09 AM, Mike Thomsen wrote:
>> Yeah, it was a problem on my end. Not just the content-type as you
>> suggested, but I had to wrap that whole JSON body so it looked like this:
>>
>> {
>> "params": { ///That block pasted here }
>> }
>
> I'm surprised you can get JSON to work at all.
Support for a JSON query body was added in 5x.
Still kind of experimental... I haven't had the time to flesh it out
more, but you can just put all the normal query params in the "params"
block.
http://yonik.com/solr-json-request-api/
-Yonik
Re: /select changes between 4 and 5
Posted by Shawn Heisey <ap...@elyograg.org>.
On 2/24/2016 9:09 AM, Mike Thomsen wrote:
> Yeah, it was a problem on my end. Not just the content-type as you
> suggested, but I had to wrap that whole JSON body so it looked like this:
>
> {
> "params": { ///That block pasted here }
> }
I'm surprised you can get JSON to work at all. I would expect the
needed format to be what browsers send when they do a post from an html
form, like the example Yonik tried.
Whatever is parsing those parameters, whether it is Solr or or the
servlet container, probably got more restrictive about the format in
5.x. Solr 5.x uses Jetty 9 for running servlets. There's no way for me
to know what container you were using with the 4.10 version.
Is there documentation somewhere for using a JSON post body with Solr?
Thanks,
Shawn
Re: /select changes between 4 and 5
Posted by Mike Thomsen <mi...@gmail.com>.
Yeah, it was a problem on my end. Not just the content-type as you
suggested, but I had to wrap that whole JSON body so it looked like this:
{
"params": { ///That block pasted here }
}
On Wed, Feb 24, 2016 at 11:05 AM, Yonik Seeley <ys...@gmail.com> wrote:
> POST in general still works for queries... I just verified it:
>
> curl -XPOST "http://localhost:8983/solr/techproducts/select" -d "q=*:*"
>
> Maybe it's your content-type (since it seems like you are posting
> Python)... Were you using some sort of custom code that could
> read/accept other content types?
>
> -Yonik
>
>
> On Wed, Feb 24, 2016 at 8:48 AM, Mike Thomsen <mi...@gmail.com>
> wrote:
> > With 4.10, we used to post JSON like this example (part of it is Python)
> to
> > /select:
> >
> > {
> > "q": "LONG_QUERY_HERE",
> > "fq": fq,
> > "fl": ["id", "title", "date_of_information", "link", "search_text"],
> > "rows": 100,
> > "wt": "json",
> > "indent": "true",
> > "_": int(time.time())
> > }
> >
> > We just upgraded to 5.4.1, and now we can't seem to POST anything to
> > /select. I tried it out in the admin tool, and it only does GET
> operations
> > against /select (tried changing it to POST and moving query string to the
> > body with Firefox dev tools, but that failed).
> >
> > Is there a way to keep doing something like what we were doing or do we
> > need to limit ourselves to GETs? I think our queries are all small enough
> > now for that, but it would helpful to know for planning.
> >
> > Thanks,
> >
> > Mike
>
Re: /select changes between 4 and 5
Posted by Yonik Seeley <ys...@gmail.com>.
POST in general still works for queries... I just verified it:
curl -XPOST "http://localhost:8983/solr/techproducts/select" -d "q=*:*"
Maybe it's your content-type (since it seems like you are posting
Python)... Were you using some sort of custom code that could
read/accept other content types?
-Yonik
On Wed, Feb 24, 2016 at 8:48 AM, Mike Thomsen <mi...@gmail.com> wrote:
> With 4.10, we used to post JSON like this example (part of it is Python) to
> /select:
>
> {
> "q": "LONG_QUERY_HERE",
> "fq": fq,
> "fl": ["id", "title", "date_of_information", "link", "search_text"],
> "rows": 100,
> "wt": "json",
> "indent": "true",
> "_": int(time.time())
> }
>
> We just upgraded to 5.4.1, and now we can't seem to POST anything to
> /select. I tried it out in the admin tool, and it only does GET operations
> against /select (tried changing it to POST and moving query string to the
> body with Firefox dev tools, but that failed).
>
> Is there a way to keep doing something like what we were doing or do we
> need to limit ourselves to GETs? I think our queries are all small enough
> now for that, but it would helpful to know for planning.
>
> Thanks,
>
> Mike