RE: creating an index using Python?

Hi good day,

I have a question regarding creating an ElasticSearch index using Python
Requests Library ( http://docs.python-requests.org/en/latest/ )

I'm not too sure if the issue I am having is with ElasticSearch or with
Python Requests library....

Background:
I'm using Requests for perform cURL requests to a ElasticSearch endpoint (
http://www.elasticsearch
.org/guide/reference/api/admin-indices-create-index.html )

In particular, I am trying to create an index setting.

This code works:
( on command line )

eugene$: curl -XPUT 'http://localhost:9200/testindex4' -d '{"settings": {
"index" : { "number_of_shards":3,"number_of_replicas":2}}}'

The above creates the expected settings.

However, doing the same thing using Requests does not work:

test_settings = {'settings': {'index': {'number_of_replicas': 2,
'number_of_shards': 3}}}

create an index with test_settings:

index_test = requests.put('http://localhost:9200/testindex',
data=test_settings) # this line is successful

get the settings of index_test

check_settings = requests.get('http://localhost:9200/testindex/_settings')
print check_settings.json()

returns the following:

{u'index_test': {u'settings': {u'index.version.created': u'200299',
u'index.number_of_shards': u'5', u'index.number_of_replicas': u'1',
u'index.settings': u'index'}}}

Notice that the index.number_of_replicas is not 2, and
index.number_of_shards is not 3.

I was wondering if there's a bug with Requests? Or is it a problem with
elasticsearch ?

Is there any way I can create an index via the Python Request Library ? (
or perhaps cURL library? )

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You need to send the a json string...

index_test = requests.put('http://localhost:9200/testindex',
data=json.dumps(test_settings))

On Sunday, February 10, 2013 10:19:47 AM UTC-5, Elastic Noob wrote:

Hi good day,

I have a question regarding creating an ElasticSearch index using Python
Requests Library ( http://docs.python-requests.org/en/latest/ )

I'm not too sure if the issue I am having is with ElasticSearch or with
Python Requests library....

Background:
I'm using Requests for perform cURL requests to a ElasticSearch endpoint
( http://www.elasticsearch
.org/guide/reference/api/admin-indices-create-index.html )

In particular, I am trying to create an index setting.

This code works:
( on command line )

eugene$: curl -XPUT 'http://localhost:9200/testindex4' -d '{"settings": {
"index" : { "number_of_shards":3,"number_of_replicas":2}}}'

The above creates the expected settings.

However, doing the same thing using Requests does not work:

test_settings = {'settings': {'index': {'number_of_replicas': 2,
'number_of_shards': 3}}}

create an index with test_settings:

index_test = requests.put('http://localhost:9200/testindex',
data=test_settings) # this line is successful

get the settings of index_test

check_settings = requests.get('http://localhost:9200/testindex/_settings')
print check_settings.json()

returns the following:

{u'index_test': {u'settings': {u'index.version.created': u'200299',
u'index.number_of_shards': u'5', u'index.number_of_replicas': u'1',
u'index.settings': u'index'}}}

Notice that the index.number_of_replicas is not 2, and
index.number_of_shards is not 3.

I was wondering if there's a bug with Requests? Or is it a problem with
elasticsearch ?

Is there any way I can create an index via the Python Request Library ? (
or perhaps cURL library? )

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

There is a very good Python package for Elasticsearch called pyes:

...Ken

On Sun, Feb 10, 2013 at 9:36 AM, egaumer egaumer@gmail.com wrote:

You need to send the a json string...

index_test = requests.put('http://localhost:9200/testindex',
data=json.dumps(test_settings))

On Sunday, February 10, 2013 10:19:47 AM UTC-5, Elastic Noob wrote:

Hi good day,

I have a question regarding creating an ElasticSearch index using Python
Requests Library ( http://docs.python-requests.org/en/latest/ )

I'm not too sure if the issue I am having is with ElasticSearch or with
Python Requests library....

Background:
I'm using Requests for perform cURL requests to a ElasticSearch endpoint (
http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html
)

In particular, I am trying to create an index setting.

This code works:
( on command line )

eugene$: curl -XPUT 'http://localhost:9200/testindex4' -d '{"settings": {
"index" : { "number_of_shards":3,"number_of_replicas":2}}}'

The above creates the expected settings.

However, doing the same thing using Requests does not work:

test_settings = {'settings': {'index': {'number_of_replicas': 2,
'number_of_shards': 3}}}

create an index with test_settings:

index_test = requests.put('http://localhost:9200/testindex',
data=test_settings) # this line is successful

get the settings of index_test

check_settings = requests.get('http://localhost:9200/testindex/_settings')
print check_settings.json()

returns the following:

{u'index_test': {u'settings': {u'index.version.created': u'200299',
u'index.number_of_shards': u'5', u'index.number_of_replicas': u'1',
u'index.settings': u'index'}}}

Notice that the index.number_of_replicas is not 2, and
index.number_of_shards is not 3.

I was wondering if there's a bug with Requests? Or is it a problem with
elasticsearch ?

Is there any way I can create an index via the Python Request Library ? (
or perhaps cURL library? )

Thanks!

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi, thanks for the reply!

The library don't seem to be updated recently.

Is there any other libraries? Or is the library in question working alright
in your experience ?

Best .

On Monday, February 11, 2013 9:49:14 PM UTC+8, Kenneth Loafman wrote:

There is a very good Python package for Elasticsearch called pyes:
https://github.com/aparo/pyes

...Ken

On Sun, Feb 10, 2013 at 9:36 AM, egaumer <ega...@gmail.com <javascript:>>
wrote:

You need to send the a json string...

index_test = requests.put('http://localhost:9200/testindex',
data=json.dumps(test_settings))

On Sunday, February 10, 2013 10:19:47 AM UTC-5, Elastic Noob wrote:

Hi good day,

I have a question regarding creating an ElasticSearch index using
Python

Requests Library ( http://docs.python-requests.org/en/latest/ )

I'm not too sure if the issue I am having is with ElasticSearch or with
Python Requests library....

Background:
I'm using Requests for perform cURL requests to a ElasticSearch
endpoint (

http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html

)

In particular, I am trying to create an index setting.

This code works:
( on command line )

eugene$: curl -XPUT 'http://localhost:9200/testindex4' -d
'{"settings": {

"index" : { "number_of_shards":3,"number_of_replicas":2}}}'

The above creates the expected settings.

However, doing the same thing using Requests does not work:

test_settings = {'settings': {'index': {'number_of_replicas': 2,
'number_of_shards': 3}}}

create an index with test_settings:

index_test = requests.put('http://localhost:9200/testindex',
data=test_settings) # this line is successful

get the settings of index_test

check_settings = requests.get('
http://localhost:9200/testindex/_settings')

print check_settings.json()

returns the following:

{u'index_test': {u'settings': {u'index.version.created': u'200299',
u'index.number_of_shards': u'5', u'index.number_of_replicas': u'1',
u'index.settings': u'index'}}}

Notice that the index.number_of_replicas is not 2, and
index.number_of_shards is not 3.

I was wondering if there's a bug with Requests? Or is it a problem with
elasticsearch ?

Is there any way I can create an index via the Python Request Library ?
(

or perhaps cURL library? )

Thanks!

--
You received this message because you are subscribed to the Google
Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Got it!

Thanks!

On Sunday, February 10, 2013 11:36:56 PM UTC+8, egaumer wrote:

You need to send the a json string...

index_test = requests.put('http://localhost:9200/testindex',
data=json.dumps(test_settings))

On Sunday, February 10, 2013 10:19:47 AM UTC-5, Elastic Noob wrote:

Hi good day,

I have a question regarding creating an ElasticSearch index using Python
Requests Library ( http://docs.python-requests.org/en/latest/ )

I'm not too sure if the issue I am having is with ElasticSearch or with
Python Requests library....

Background:
I'm using Requests for perform cURL requests to a ElasticSearch endpoint
( http://www.elasticsearch
.org/guide/reference/api/admin-indices-create-index.html )

In particular, I am trying to create an index setting.

This code works:
( on command line )

eugene$: curl -XPUT 'http://localhost:9200/testindex4' -d '{"settings":
{ "index" : { "number_of_shards":3,"number_of_replicas":2}}}'

The above creates the expected settings.

However, doing the same thing using Requests does not work:

test_settings = {'settings': {'index': {'number_of_replicas': 2,
'number_of_shards': 3}}}

create an index with test_settings:

index_test = requests.put('http://localhost:9200/testindex',
data=test_settings) # this line is successful

get the settings of index_test

check_settings = requests.get('http://localhost:9200/testindex/_settings
')
print check_settings.json()

returns the following:

{u'index_test': {u'settings': {u'index.version.created': u'200299',
u'index.number_of_shards': u'5', u'index.number_of_replicas': u'1',
u'index.settings': u'index'}}}

Notice that the index.number_of_replicas is not 2, and
index.number_of_shards is not 3.

I was wondering if there's a bug with Requests? Or is it a problem with
elasticsearch ?

Is there any way I can create an index via the Python Request Library ? (
or perhaps cURL library? )

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.