question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How pysolr import UTF-8 data to Solr server?

See original GitHub issue

I have a request look like this:

    solr.add(    [
        {
            "id": "1",
            "title": "đinh bộ linh",
            "content": ["ông bà "]
        }]
)

When i call this request. Having a error like this:

Traceback (most recent call last):
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\threading.py", line 914, in _
bootstrap_inner
    self.run()
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\threading.py", line 1180, in
run
    self.function(*self.args, **self.kwargs)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mysql_replicati
on-0.7-py3.5.egg\pymysqlreplication\row_event.py", line 739, in AddThread
    solr.add(value["value"])
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pysolr-3.3.3-py
3.5.egg\pysolr.py", line 822, in add
    return self._update(m, commit=commit, softCommit=softCommit, waitFlush=waitFlush, waitSearcher=w
aitSearcher)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pysolr-3.3.3-py
3.5.egg\pysolr.py", line 400, in _update
    return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pysolr-3.3.3-py
3.5.egg\pysolr.py", line 309, in _send_request
    timeout=self.timeout)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\sessions.py", line 511, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\sessions.py", line 454, in request
    prep = self.prepare_request(req)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\sessions.py", line 388, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\models.py", line 308, in prepare
    self.prepare_body(data, files, json)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\models.py", line 459, in prepare_body
    body = self._encode_params(data)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\models.py", line 85, in _encode_params
    return to_native_string(data)
  File "C:\Users\dungdb1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.0-
py3.5.egg\requests\utils.py", line 702, in to_native_string
    out = string.decode(encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 91: ordinal not in range(128)

how can you send that to solr using pysolr? Pls help me! Thanks

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
joshuajonahcommented, Sep 20, 2016

I did some research into fixing the issue with sending a UTF-8 body in requests only to find that my version was behind, it was fixed here: https://github.com/kennethreitz/requests/commit/b32c3bc10f0fb4075b6a282b283418f5290e812a

Feeling pretty silly here. If you have this issue anybody, update your outdated Requests.

0reactions
joshuajonahcommented, Sep 20, 2016

That was fixed in 2.9.1

On Sep 20, 2016 9:51 AM, “Chris Adams” notifications@github.com wrote:

Thanks! What version was that fix in? I’ll update pysolr to depend on the newer release.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/django-haystack/pysolr/issues/177#issuecomment-248305962, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHVpUqMOYJuW4-H_D-NDP3jNmOY1vAfks5qr-PtgaJpZM4HElrG .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - How pysolr import UTF-8 data to Solr server? -
How pysolr import UTF-8 data to Solr server ? django-haystack. 13 January 2016 Posted by dungdb1. I have a request look like this:...
Read more >
Using pysolr getting 400 error when trying to add data to solr
The fields that I'm using here are dynamic fields. No issue with connecting to solr. #/usr/bin/python import pysolr solr = pysolr.Solr('http ...
Read more >
Uploading Structured Data Store Data with the Data Import ...
An annotated configuration file, based on the db collection in the dih example server, is shown below (this file is located in example/example-DIH/solr/db/conf/ ......
Read more >
Indexing csv data in Solr via Python – PySolr - ConfusedCoders
Here is a crisp post to index Data in Solr using Python. ... import pysolr. import csv, json ... create a connection to...
Read more >
Search for model legislation in over one million bills using ...
Checking for legislative text reuse using Python, Solr, and simple text search ... import pysolr import requests from sqlalchemy import create_engine import ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found