Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected keyword argument 'fields' with -f option #14

Closed
bartclarkson opened this issue Oct 21, 2016 · 7 comments
Closed

unexpected keyword argument 'fields' with -f option #14

bartclarkson opened this issue Oct 21, 2016 · 7 comments

Comments

@bartclarkson
Copy link

Hello-

I can run this command without the fields option successfully. Inclusion of the -f options fails with the following response. Example of command follows that.

Thank you for this tool. It seems like one of the more popular ES GUI tools should integrate with it.

Trackback error:

Traceback (most recent call last):
File "/usr/local/bin/es2csv", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/es2csv.py", line 268, in main
es.search_query()
File "/usr/local/lib/python2.7/dist-packages/es2csv.py", line 40, in f_retry
return f(_args, _kwargs)
File "/usr/local/lib/python2.7/dist-packages/es2csv.py", line 123, in search_query
res = self.es_conn.search(
_search_args)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 71, in _wrapped
return func(_args, params=params, **kwargs)
TypeError: search() got an unexpected keyword argument 'fields'

Example of command:
es2csv -i se-account-base -q "(country:usa AND account_type:regular AND date_inception:{2012-01-01 TO 2017-01-01}) NOT (restriction_type_2:deceased)" -f account_number title first_name middle_name last_name -o /usr/share/csv/account_base_3rd_party.csv

@taraslayshchuk
Copy link
Owner

Hello

What version do you use?
Probably looks like that there is issue with elasticsearch.py library.

@rdica
Copy link

rdica commented Oct 24, 2016

I too am having same issue,
sudo pip install es2csv
Collecting es2csv
Downloading es2csv-1.0.3-py2-none-any.whl
Collecting progressbar>=2.3 (from es2csv)
Downloading progressbar-2.3.tar.gz
Collecting elasticsearch>=2.3.0 (from es2csv)
Downloading elasticsearch-5.0.0-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 57kB 1.5MB/s
Requirement already satisfied (use --upgrade to upgrade): urllib3<2.0,>=1.8 in /usr/lib/python2.7/site-packages (from elasticsearch>=2.3.0->es2csv)
Installing collected packages: progressbar, elasticsearch, es2csv
Running setup.py install for progressbar ... done
Successfully installed elasticsearch-5.0.0 es2csv-1.0.3 progressbar-2.3
You are using pip version 8.0.2, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Fedora 24.

@rdica
Copy link

rdica commented Oct 24, 2016

Just tried a fresh pip install on ubuntu 16.04, same issue. Tried field args as space delimnited, also tried as ['var1','var2']

@taraslayshchuk
Copy link
Owner

Thanks, @rdica.

Issue in this:

Downloading elasticsearch-5.0.0-py2.py3-none-any.whl

They have broken API again: 2.3.0 has fields arg and 5.0.0 has not. It was renamed.
Hot fix is to downgrade to version 2.3.0. I am going to bring proper version dependency in future.

@rdica
Copy link

rdica commented Oct 24, 2016

@taraslayshchuk
Thanks, that works...I pip unistalled es5 and installed 2.3.0...I noticed that the order of fields given is resorted alphabetically in the CSV file, is that intended behaviour? thanks again

@bartclarkson
Copy link
Author

Thanks. Here's the provisioning bash I'm using to implement the fix described in this thread. I happen to be using ES 2.3 in my environment, as reflected below. I'm going to close this issue, as I assume (improved) compatibility with Python ES 5.0 is broader in scope.

apt-get install -y -python-pip git
pip install git+https://github.com/taraslayshchuk/es2csv.git
pip uninstall -y elasticsearch
pip install elasticsearch==2.3

@taraslayshchuk
Copy link
Owner

@rdica, Yes, it is sorted.
@bartclarkson, not sure about a migration process to ES 5.0 at the moment, I am planning to hardcore dependency elasticsearch-2.*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants