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 Kojo <rb...@gmail.com> on 2018/05/08 17:36:06 UTC

Solr Json Facet

Hello,
recently I have changed the way I get facet data from Solr. I was using GET
method on request but due to the limit of the query I changed to POST
method.

Bellow is a sample of the data I send to Solr, in order to get facets. But
there is something here that I don´t understand.

If I do not tag the fq query, it woks fine:
{'q':'*:*', 'fl': '*', 'fq':'city_colaboration:"College Station"',
'json.facet': '{city_colaboration:{type:terms, field: city_colaboration
,limit:5000}}'}

If I tag the fq query and I query for a simple word it works fine too. But
if query a multi word with space in the middle it breaks:

{'q':'*:*', 'fl': '*',
'fq':'{!tag=city_colaboration_tag}city_colaboration:"College
Station"', 'json.facet': '{city_colaboration:{type:terms, field:
city_colaboration ,limit:5000, domain:{excludeTags:city_
colaboration_tag}}}'}


All of this works fine for GET method, but breks on POST method.


Below is the portion of the log. I really appreciate your help.

Regards,
Koji



01:49
ERROR true
RequestHandlerBase
org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError:
Cannot parse 'city_colaboration:"College': Lexical error at line 1,&#8203;
column 34. Encountered: <EOF> after : "\"College"
org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError:
Cannot parse 'cidade_colaboracao_exact:"College': Lexical error at line 1,
column 34.  Encountered: <EOF> after : "\"College"
at org.apache.solr.handler.component.QueryComponent.
prepare(QueryComponent.java:219)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(
SearchHandler.java:270)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(
RequestHandlerBase.java:173)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:2477)
at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:723)
at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:529)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
SolrDispatchFilter.java:361)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
SolrDispatchFilter.java:305)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
doFilter(ServletHandler.java:1691)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
ServletHandler.java:582)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(
SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.
doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.
doHandle(ContextHandler.java:1180)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
at org.eclipse.jetty.server.session.SessionHandler.
doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.
doScope(ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerCollection.
handle(HandlerCollection.java:119)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
HandlerWrapper.java:134)
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(
RewriteHandler.java:335)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:534)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
at org.eclipse.jetty.server.HttpConnection.onFillable(
HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(
AbstractConnection.java:273)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(
SelectChannelEndPoint.java:93)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.
executeProduceConsume(ExecuteProduceConsume.java:303)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.
produceConsume(ExecuteProduceConsume.java:148)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(
ExecuteProduceConsume.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(
QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:748)

Re: Solr Json Facet

Posted by Mikhail Khludnev <mk...@apache.org>.
Single backslash escaping works for me.

On Tue, May 8, 2018 at 8:36 PM, Kojo <rb...@gmail.com> wrote:

> Hello,
> recently I have changed the way I get facet data from Solr. I was using GET
> method on request but due to the limit of the query I changed to POST
> method.
>
> Bellow is a sample of the data I send to Solr, in order to get facets. But
> there is something here that I don´t understand.
>
> If I do not tag the fq query, it woks fine:
> {'q':'*:*', 'fl': '*', 'fq':'city_colaboration:"College Station"',
> 'json.facet': '{city_colaboration:{type:terms, field: city_colaboration
> ,limit:5000}}'}
>
> If I tag the fq query and I query for a simple word it works fine too. But
> if query a multi word with space in the middle it breaks:
>
> {'q':'*:*', 'fl': '*',
> 'fq':'{!tag=city_colaboration_tag}city_colaboration:"College
> Station"', 'json.facet': '{city_colaboration:{type:terms, field:
> city_colaboration ,limit:5000, domain:{excludeTags:city_
> colaboration_tag}}}'}
>
>
> All of this works fine for GET method, but breks on POST method.
>
>
> Below is the portion of the log. I really appreciate your help.
>
> Regards,
> Koji
>
>
>
> 01:49
> ERROR true
> RequestHandlerBase
> org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError:
> Cannot parse 'city_colaboration:"College': Lexical error at line 1,&#8203;
> column 34. Encountered: <EOF> after : "\"College"
> org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError:
> Cannot parse 'cidade_colaboracao_exact:"College': Lexical error at line 1,
> column 34.  Encountered: <EOF> after : "\"College"
> at org.apache.solr.handler.component.QueryComponent.
> prepare(QueryComponent.java:219)
> at org.apache.solr.handler.component.SearchHandler.handleRequestBody(
> SearchHandler.java:270)
> at org.apache.solr.handler.RequestHandlerBase.handleRequest(
> RequestHandlerBase.java:173)
> at org.apache.solr.core.SolrCore.execute(SolrCore.java:2477)
> at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:723)
> at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:529)
> at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
> SolrDispatchFilter.java:361)
> at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
> SolrDispatchFilter.java:305)
> at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> doFilter(ServletHandler.java:1691)
> at org.eclipse.jetty.servlet.ServletHandler.doHandle(
> ServletHandler.java:582)
> at org.eclipse.jetty.server.handler.ScopedHandler.handle(
> ScopedHandler.java:143)
> at org.eclipse.jetty.security.SecurityHandler.handle(
> SecurityHandler.java:548)
> at org.eclipse.jetty.server.session.SessionHandler.
> doHandle(SessionHandler.java:226)
> at org.eclipse.jetty.server.handler.ContextHandler.
> doHandle(ContextHandler.java:1180)
> at org.eclipse.jetty.servlet.ServletHandler.doScope(
> ServletHandler.java:512)
> at org.eclipse.jetty.server.session.SessionHandler.
> doScope(SessionHandler.java:185)
> at org.eclipse.jetty.server.handler.ContextHandler.
> doScope(ContextHandler.java:1112)
> at org.eclipse.jetty.server.handler.ScopedHandler.handle(
> ScopedHandler.java:141)
> at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
> ContextHandlerCollection.java:213)
> at org.eclipse.jetty.server.handler.HandlerCollection.
> handle(HandlerCollection.java:119)
> at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
> HandlerWrapper.java:134)
> at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(
> RewriteHandler.java:335)
> at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
> HandlerWrapper.java:134)
> at org.eclipse.jetty.server.Server.handle(Server.java:534)
> at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
> at org.eclipse.jetty.server.HttpConnection.onFillable(
> HttpConnection.java:251)
> at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(
> AbstractConnection.java:273)
> at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
> at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(
> SelectChannelEndPoint.java:93)
> at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.
> executeProduceConsume(ExecuteProduceConsume.java:303)
> at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.
> produceConsume(ExecuteProduceConsume.java:148)
> at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(
> ExecuteProduceConsume.java:136)
> at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
> QueuedThreadPool.java:671)
> at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(
> QueuedThreadPool.java:589)
> at java.lang.Thread.run(Thread.java:748)
>



-- 
Sincerely yours
Mikhail Khludnev

Re: Solr Json Facet

Posted by Erick Erickson <er...@gmail.com>.
Follow the instructions here:
http://lucene.apache.org/solr/community.html#mailing-lists-irc. You
must use the _exact_ same e-mail as you used to subscribe.

If the initial try doesn't work and following the suggestions at the
"problems" link doesn't work for you, let us know. But note you need
to show us the _entire_ return header to allow anyone to diagnose the
problem.


On Tue, May 8, 2018 at 9:23 PM, Asher Shih <ca...@gmail.com> wrote:
> unsubscribe
>
> On Tue, May 8, 2018 at 9:19 PM, Kojo <rb...@gmail.com> wrote:
>> Everything working now. The code is not that clean and I am rewriting, so I
>> don't know exactly what was wrong, but something malformed.
>>
>> I would like to ask another question regarding json facet.
>>
>> With GET method, i was used to use many fq on the same query, each one with
>> it's own tag. It was working wondefully.
>>
>> With POST method, to post more than one fq parameter is a little
>> complicated, so I am joining all queries in one fq with all the tags. When
>> I select the first facet everything seems to be ok, but when I select the
>> second facet it is "cleaning" the first filter for the facets which shows
>> all the original values for this second facet, even though the result-set
>> is filtering as expected. I will make more tests to understand the
>> mechanics of this, but if someone has some advise on this subject I
>> appreciate a lot.
>>
>> Thank you,
>>
>>
>>
>>
>>
>> 2018-05-08 23:54 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>>
>>> Looks like some sort of proxy server inbetween the python client and
>>> solr server.
>>> I would still check first if the output from the python client is
>>> correctly escaped/encoded HTTP.
>>>
>>> One easy way is to use netcat to pretend to be a server:
>>> $ nc -l 8983
>>> And then send point the python client at that and send the request.
>>>
>>> -Yonik
>>>
>>>
>>> On Tue, May 8, 2018 at 9:17 PM, Kojo <rb...@gmail.com> wrote:
>>> > Thank you all. I tried escaping but still not working
>>> >
>>> > Yonik, I am using Python Requests. It works if my fq is a single word,
>>> even
>>> > if I use double quotes on this single word without escaping.
>>> >
>>> > This is the HTTP response:
>>> >
>>> > response.content
>>> > <Response [400]>
>>> > '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
>>> > 2.0//EN">\n<html><head>\n<title>400 Bad
>>> > Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser
>>> sent
>>> > a request that this server could not understand.<br
>>> > />\n</p>\n<hr>\n<address>Apache/2.2.15 (Oracle) Server at leydenh Port
>>> > 80</address>\n</body></html>\n'
>>> >
>>> >
>>> > Thank you,
>>> >
>>> >
>>> >
>>> > 2018-05-08 18:46 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>>> >
>>> >> On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
>>> >> > If I tag the fq query and I query for a simple word it works fine too.
>>> >> But
>>> >> > if query a multi word with space in the middle it breaks:
>>> >>
>>> >> Most likely the full query is not getting to Solr because of an HTTP
>>> >> protocol error (i.e. the request is not encoded correctly).
>>> >> How are you sending your request to Solr (with curl, or with some other
>>> >> method?)
>>> >>
>>> >> -Yonik
>>> >>
>>>

Re: Solr Json Facet

Posted by Asher Shih <ca...@gmail.com>.
unsubscribe

On Tue, May 8, 2018 at 9:19 PM, Kojo <rb...@gmail.com> wrote:
> Everything working now. The code is not that clean and I am rewriting, so I
> don't know exactly what was wrong, but something malformed.
>
> I would like to ask another question regarding json facet.
>
> With GET method, i was used to use many fq on the same query, each one with
> it's own tag. It was working wondefully.
>
> With POST method, to post more than one fq parameter is a little
> complicated, so I am joining all queries in one fq with all the tags. When
> I select the first facet everything seems to be ok, but when I select the
> second facet it is "cleaning" the first filter for the facets which shows
> all the original values for this second facet, even though the result-set
> is filtering as expected. I will make more tests to understand the
> mechanics of this, but if someone has some advise on this subject I
> appreciate a lot.
>
> Thank you,
>
>
>
>
>
> 2018-05-08 23:54 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>
>> Looks like some sort of proxy server inbetween the python client and
>> solr server.
>> I would still check first if the output from the python client is
>> correctly escaped/encoded HTTP.
>>
>> One easy way is to use netcat to pretend to be a server:
>> $ nc -l 8983
>> And then send point the python client at that and send the request.
>>
>> -Yonik
>>
>>
>> On Tue, May 8, 2018 at 9:17 PM, Kojo <rb...@gmail.com> wrote:
>> > Thank you all. I tried escaping but still not working
>> >
>> > Yonik, I am using Python Requests. It works if my fq is a single word,
>> even
>> > if I use double quotes on this single word without escaping.
>> >
>> > This is the HTTP response:
>> >
>> > response.content
>> > <Response [400]>
>> > '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
>> > 2.0//EN">\n<html><head>\n<title>400 Bad
>> > Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser
>> sent
>> > a request that this server could not understand.<br
>> > />\n</p>\n<hr>\n<address>Apache/2.2.15 (Oracle) Server at leydenh Port
>> > 80</address>\n</body></html>\n'
>> >
>> >
>> > Thank you,
>> >
>> >
>> >
>> > 2018-05-08 18:46 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>> >
>> >> On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
>> >> > If I tag the fq query and I query for a simple word it works fine too.
>> >> But
>> >> > if query a multi word with space in the middle it breaks:
>> >>
>> >> Most likely the full query is not getting to Solr because of an HTTP
>> >> protocol error (i.e. the request is not encoded correctly).
>> >> How are you sending your request to Solr (with curl, or with some other
>> >> method?)
>> >>
>> >> -Yonik
>> >>
>>

Re: Solr Json Facet

Posted by Kojo <rb...@gmail.com>.
Only for the records, I will describe here what I did to solve this
problem. This is specific for those who are using python/requests and Solr
json facet api.


I would like to ask another question regarding json facet.
>
> With GET method, i was used to use many fq on the same query, each one
> with it's own tag. It was working wondefully.
>
> With POST method, to post more than one fq parameter is a little
> complicated, so I am joining all queries in one fq with all the tags. When
> I select the first facet everything seems to be ok, but when I select the
> second facet it is "cleaning" the first filter for the facets which shows
> all the original values for this second facet, even though the result-set
> is filtering as expected. I will make more tests to understand the
> mechanics of this, but if someone has some advise on this subject I
> appreciate a lot.
>


I was not aware how to POST data with same key on Python. It was due to my
unfamiliarity of the details of the protocol and the libs.
In python/requests library, one way to send data over POST is to use a
dictionary, that has a unique key by design.

But I realise that I can send data as a list of tuples like this:
[('q','*:*'), ('fl','*'), ('json.facet',facet_fields), ('fq', 'fq_1'),
'fq', 'fq_2'),  'fq', 'fq_3')]

The facet layer of my system now works entirely  using solr json facet api
over http post.












>
>
>
>
> 2018-05-08 23:54 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>
>> Looks like some sort of proxy server inbetween the python client and
>> solr server.
>> I would still check first if the output from the python client is
>> correctly escaped/encoded HTTP.
>>
>> One easy way is to use netcat to pretend to be a server:
>> $ nc -l 8983
>> And then send point the python client at that and send the request.
>>
>> -Yonik
>>
>>
>> On Tue, May 8, 2018 at 9:17 PM, Kojo <rb...@gmail.com> wrote:
>> > Thank you all. I tried escaping but still not working
>> >
>> > Yonik, I am using Python Requests. It works if my fq is a single word,
>> even
>> > if I use double quotes on this single word without escaping.
>> >
>> > This is the HTTP response:
>> >
>> > response.content
>> > <Response [400]>
>> > '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
>> > 2.0//EN">\n<html><head>\n<title>400 Bad
>> > Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser
>> sent
>> > a request that this server could not understand.<br
>> > />\n</p>\n<hr>\n<address>Apache/2.2.15 (Oracle) Server at leydenh Port
>> > 80</address>\n</body></html>\n'
>> >
>> >
>> > Thank you,
>> >
>> >
>> >
>> > 2018-05-08 18:46 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>> >
>> >> On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
>> >> > If I tag the fq query and I query for a simple word it works fine
>> too.
>> >> But
>> >> > if query a multi word with space in the middle it breaks:
>> >>
>> >> Most likely the full query is not getting to Solr because of an HTTP
>> >> protocol error (i.e. the request is not encoded correctly).
>> >> How are you sending your request to Solr (with curl, or with some other
>> >> method?)
>> >>
>> >> -Yonik
>> >>
>>
>
>

Re: Solr Json Facet

Posted by Kojo <rb...@gmail.com>.
Everything working now. The code is not that clean and I am rewriting, so I
don't know exactly what was wrong, but something malformed.

I would like to ask another question regarding json facet.

With GET method, i was used to use many fq on the same query, each one with
it's own tag. It was working wondefully.

With POST method, to post more than one fq parameter is a little
complicated, so I am joining all queries in one fq with all the tags. When
I select the first facet everything seems to be ok, but when I select the
second facet it is "cleaning" the first filter for the facets which shows
all the original values for this second facet, even though the result-set
is filtering as expected. I will make more tests to understand the
mechanics of this, but if someone has some advise on this subject I
appreciate a lot.

Thank you,





2018-05-08 23:54 GMT-03:00 Yonik Seeley <ys...@gmail.com>:

> Looks like some sort of proxy server inbetween the python client and
> solr server.
> I would still check first if the output from the python client is
> correctly escaped/encoded HTTP.
>
> One easy way is to use netcat to pretend to be a server:
> $ nc -l 8983
> And then send point the python client at that and send the request.
>
> -Yonik
>
>
> On Tue, May 8, 2018 at 9:17 PM, Kojo <rb...@gmail.com> wrote:
> > Thank you all. I tried escaping but still not working
> >
> > Yonik, I am using Python Requests. It works if my fq is a single word,
> even
> > if I use double quotes on this single word without escaping.
> >
> > This is the HTTP response:
> >
> > response.content
> > <Response [400]>
> > '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
> > 2.0//EN">\n<html><head>\n<title>400 Bad
> > Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser
> sent
> > a request that this server could not understand.<br
> > />\n</p>\n<hr>\n<address>Apache/2.2.15 (Oracle) Server at leydenh Port
> > 80</address>\n</body></html>\n'
> >
> >
> > Thank you,
> >
> >
> >
> > 2018-05-08 18:46 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
> >
> >> On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
> >> > If I tag the fq query and I query for a simple word it works fine too.
> >> But
> >> > if query a multi word with space in the middle it breaks:
> >>
> >> Most likely the full query is not getting to Solr because of an HTTP
> >> protocol error (i.e. the request is not encoded correctly).
> >> How are you sending your request to Solr (with curl, or with some other
> >> method?)
> >>
> >> -Yonik
> >>
>

Re: Solr Json Facet

Posted by Yonik Seeley <ys...@gmail.com>.
Looks like some sort of proxy server inbetween the python client and
solr server.
I would still check first if the output from the python client is
correctly escaped/encoded HTTP.

One easy way is to use netcat to pretend to be a server:
$ nc -l 8983
And then send point the python client at that and send the request.

-Yonik


On Tue, May 8, 2018 at 9:17 PM, Kojo <rb...@gmail.com> wrote:
> Thank you all. I tried escaping but still not working
>
> Yonik, I am using Python Requests. It works if my fq is a single word, even
> if I use double quotes on this single word without escaping.
>
> This is the HTTP response:
>
> response.content
> <Response [400]>
> '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
> 2.0//EN">\n<html><head>\n<title>400 Bad
> Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent
> a request that this server could not understand.<br
> />\n</p>\n<hr>\n<address>Apache/2.2.15 (Oracle) Server at leydenh Port
> 80</address>\n</body></html>\n'
>
>
> Thank you,
>
>
>
> 2018-05-08 18:46 GMT-03:00 Yonik Seeley <ys...@gmail.com>:
>
>> On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
>> > If I tag the fq query and I query for a simple word it works fine too.
>> But
>> > if query a multi word with space in the middle it breaks:
>>
>> Most likely the full query is not getting to Solr because of an HTTP
>> protocol error (i.e. the request is not encoded correctly).
>> How are you sending your request to Solr (with curl, or with some other
>> method?)
>>
>> -Yonik
>>

Re: Solr Json Facet

Posted by Kojo <rb...@gmail.com>.
Thank you all. I tried escaping but still not working

Yonik, I am using Python Requests. It works if my fq is a single word, even
if I use double quotes on this single word without escaping.

This is the HTTP response:

response.content
<Response [400]>
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
2.0//EN">\n<html><head>\n<title>400 Bad
Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent
a request that this server could not understand.<br
/>\n</p>\n<hr>\n<address>Apache/2.2.15 (Oracle) Server at leydenh Port
80</address>\n</body></html>\n'


Thank you,



2018-05-08 18:46 GMT-03:00 Yonik Seeley <ys...@gmail.com>:

> On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
> > If I tag the fq query and I query for a simple word it works fine too.
> But
> > if query a multi word with space in the middle it breaks:
>
> Most likely the full query is not getting to Solr because of an HTTP
> protocol error (i.e. the request is not encoded correctly).
> How are you sending your request to Solr (with curl, or with some other
> method?)
>
> -Yonik
>

Re: Solr Json Facet

Posted by Yonik Seeley <ys...@gmail.com>.
On Tue, May 8, 2018 at 1:36 PM, Kojo <rb...@gmail.com> wrote:
> If I tag the fq query and I query for a simple word it works fine too. But
> if query a multi word with space in the middle it breaks:

Most likely the full query is not getting to Solr because of an HTTP
protocol error (i.e. the request is not encoded correctly).
How are you sending your request to Solr (with curl, or with some other method?)

-Yonik

Re: Solr Json Facet

Posted by Shawn Heisey <ap...@elyograg.org>.
On 5/8/2018 11:36 AM, Kojo wrote:
> If I tag the fq query and I query for a simple word it works fine too. But
> if query a multi word with space in the middle it breaks:
>
> {'q':'*:*', 'fl': '*',
> 'fq':'{!tag=city_colaboration_tag}city_colaboration:"College
> Station"', 'json.facet': '{city_colaboration:{type:terms, field:
> city_colaboration ,limit:5000, domain:{excludeTags:city_
> colaboration_tag}}}'}

Best guess is that this is happening because your JSON fails
validation.  One of the rules is that quotes must be escaped if you want
to use a literal quote.

Putting your JSON into a validator, it gets flagged with a BUNCH of errors.

https://jsonformatter.curiousconcept.com/

I think I managed to fix it.  Here's a new version that passes strict
validation.  The paste will expire one month from now:

https://apaste.info/M46c

I also fixed/validated the inner json in the json.facet parameter before
I escaped it.  As you can see, nested json is messy when it is correctly
formed.

This is the tool I used for the escaping:

https://codebeautify.org/json-escape-unescape

Development libraries for constructing JSON data would probably handle
the escaping automatically.

The JSON parser that Solr uses can handle some deviations from the
strict standard, but not ALL deviations.  Using data that passes strict
validation will make success more likely.  It's not what I would do, but
you could probably also get this working just by escaping the quotes
around the query text:
\"College Station\"

Thanks,
Shawn