I found the issue. The single quotes in the request params were set to
empty and  require to be escaped with a '\'. Python instead of throwing an
error message was simply concatenating the string which is a poor design.
Below payload yields the same results as the web request in the solr
portal.

payload = {'defType':'edismax', 'fl':'*,score','rows':'3',
'fq':'Status:Active', 'bq':'{!edismax bq=\'\' mm=50% qf="ContactEmail^2
ContactName^2 URL^2 CompanyName^2"  v=$q}', 'qf':'searchfield', 'q':input}

Tanya

On Thu, Dec 13, 2018 at 10:02 AM Jan Høydahl <jan....@cominvent.com> wrote:

> Hi
>
> I don't see what the actual problem is here.
> What were you expecting to see in the response, and what do you see?
>
> Please try to reproduce the issue you think you are seeing with a tool
> like cURL, you can issue both POST and GET requests with cURL and many
> other tools. The result should be exactly the same whether you POST or GET
> your query. My guess is that you have some mismatch in encoding, escaping
> or similar in the Python Solr client you are using. So that is why I
> encourage you to reproduce the issue with cURL or in the browser.
>
> --
> Jan Høydahl, search solution architect
> Cominvent AS - www.cominvent.com
>
> > 13. des. 2018 kl. 18:52 skrev Tanya Bompi <tanya.bo...@gmail.com>:
> >
> > Hi,
> >  I have a python scraper to query the solr index and get the top 'n'
> > results and process further. What I see is with the setting of the bq
> > parameter which has a lot of special chars, the output from the python
> call
> > differs from the results I get from the query issued in the web Solr
> > portal. I am trying to understand what could be causing the differences.
> > Without the bq parameter setting, the results are the same from the
> python
> > request calls to the web output.
> >
> > The python code for the request are as follows where the params should be
> > url encoded and from what I understand no additional processing is
> needed.
> > Below is the snippet of code being issued:
> >
> > import requests
> > payload = {'defType':'edismax', 'fl':'*,score','rows':'3',
> > 'fq':'Status:Active', 'bq':'{!edismax bq='' mm=50% qf="ContactEmail^2
> > ContactName^2 URL^2 CompanyName^2"  v=$q}', 'qf':'searchfield',
> 'q':input}
> > r = requests.post(SolrIndexUrl, data=payload)
> > response = r.json()
> >
> >
> > The responseHeaders from the python call are:
> > "responseHeader":{
> >    "status":0,
> >    "QTime":0,
> >    "params":{
> >      "q":"sample input",
> >      "defType":"edismax",
> >      "qf":"searchfield",
> >      "fl":"*,score",
> >      "fq":"Status:Active",
> >      "rows":"3",
> >      "bq":"{!edismax bq= mm=50% qf=\"ContactEmail^2 ContactName^2 URL^2
> > CompanyName^2\"  v=$q}"}
> >  },
> >
> > The response headers from the Json output on the Solr Web portal are:
> > "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"sample input",
> "
> > defType":"edismax", "qf":"searchfield", "fl":"*,score",
> "fq":"Status:active",
> > "_":"1544661362690", "bq":"{!edismax bq='' mm=50% qf=\"ContactEmail^2
> > ContactName^2 URL^2 CompanyName^2\" v=$q}"}},
> >
> > The response headers seem to match but not the results output. Could
> > someone let me know what could be issue?
> >
> > Thanks,
> > Tanya
>
>

Reply via email to