Java API - Create index/mapping examples

Hi,

I'm trying to create an index and mapping using the Java API but I am not
getting the results I expect. Using the code shown in the gist below
results in the index being created, but the mapping isn't applied to the
index:

When I then hit the URL 'http://localhost:9200/testindex/_mapping', I see
the following results:

{"testindex":{"testobject":{"properties":{}}}}

Creating the index/mapping using the REST API directly via curl works. I've tried a few different permutations using the Java API based on various examples on this list without success , so I am at a bit of a loss as to what is going on here. Does anyone have some concrete examples of successfully creating an index/mapping using the Java API?

Thanks!

Tim

--
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.

Hey Tim,

Have a look at: https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/util/ESHelper.java?source=cc

I think you could find some info here.

Does it help?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 août 2013 à 12:27, tim_siney@salvationarmy.org a écrit :

Hi,

I'm trying to create an index and mapping using the Java API but I am not getting the results I expect. Using the code shown in the gist below results in the index being created, but the mapping isn't applied to the index:

When I then hit the URL 'http://localhost:9200/testindex/_mapping', I see the following results:

{"testindex":{"testobject":{"properties":{}}}}

Creating the index/mapping using the REST API directly via curl works. I've tried a few different permutations using the Java API based on various examples on this list without success , so I am at a bit of a loss as to what is going on here. Does anyone have some concrete examples of successfully creating an index/mapping using the Java API?

Thanks!

Tim

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.

Thanks David, that gave me the information I was looking for. For
reference, I refactored the code in the original email into this:

The problem with my original code was that I was trying to create the index
and mapping in the same API call. Splitting them into 2 separate calls
fixed the issue.

On Monday, August 5, 2013 1:03:22 PM UTC+1, David Pilato wrote:

Hey Tim,

Have a look at:
https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/util/ESHelper.java?source=cc

I think you could find some info here.

Does it help?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 août 2013 à 12:27, tim_...@salvationarmy.org <javascript:> a écrit :

Hi,

I'm trying to create an index and mapping using the Java API but I am not
getting the results I expect. Using the code shown in the gist below
results in the index being created, but the mapping isn't applied to the
index:

Elasticsearch Java create mapping · GitHub

When I then hit the URL 'http://localhost:9200/testindex/_mapping', I see
the following results:

{"testindex":{"testobject":{"properties":{}}}}

Creating the index/mapping using the REST API directly via curl works. I've tried a few different permutations using the Java API based on various examples on this list without success , so I am at a bit of a loss as to what is going on here. Does anyone have some concrete examples of successfully creating an index/mapping using the Java API?

Thanks!

Tim

--
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.