PutMappingRequestBuilder

Hello,

I'm trying to register a GeoPoint type with an embedded ElasticSearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Take a look to
https://github.com/elasticsearch/elasticsearch/blob/master/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceTests.java

lines 67-70

I'm doing via

client.admin()
.indices()
.putMapping(Requests.putMappingRequest(indexName)
.source(mappingSource)
.type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

So that means this API should not be used?
I would rather not have to deal with building JSON and let the API do
it.
This hides any changes to the Elasticsearch low level protocol away
from my code.

On Nov 11, 1:58 pm, maverick mauricio.alar...@gmail.com wrote:

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Elasticsearch Platform — Find real-time answers at scale | Elastic...

Take a look tohttps://github.com/elasticsearch/elasticsearch/blob/master/modules/te...

lines 67-70

I'm doing via

client.admin()
.indices()
.putMapping(Requests.putMappingRequest(indexName)
.source(mappingSource)
.type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

As far as I know this is the only way to set the mapping for an index,
is not that you're writing json on your own but instead using the java
API provided to do it.

Anybody wants to add her/his two cents here?

~M

On Nov 11, 2:55 pm, Ronak Patel ronak2...@gmail.com wrote:

So that means this API should not be used?
I would rather not have to deal with building JSON and let the API do
it.
This hides any changes to the Elasticsearch low level protocol away
from my code.

On Nov 11, 1:58 pm, maverick mauricio.alar...@gmail.com wrote:

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Elasticsearch Platform — Find real-time answers at scale | Elastic...

Take a look tohttps://github.com/elasticsearch/elasticsearch/blob/master/modules/te...

lines 67-70

I'm doing via

client.admin()
.indices()
.putMapping(Requests.putMappingRequest(indexName)
.source(mappingSource)
.type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

Some other questions related to the Java API:

Using the Java API, what is the preferred way to index a GeoPoint?

Is this not valid?

final Map<String, Object> sourceMap = new HashMap<String, Object>();
sourceMap.put("coordinate", new GeoPoint(event.getLatitudeDeg(),
event.getLongitudeDeg()));

On Nov 11, 5:11 pm, maverick mauricio.alar...@gmail.com wrote:

As far as I know this is the only way to set the mapping for an index,
is not that you're writing json on your own but instead using the java
API provided to do it.

Anybody wants to add her/his two cents here?

~M

On Nov 11, 2:55 pm, Ronak Patel ronak2...@gmail.com wrote:

So that means this API should not be used?
I would rather not have to deal with building JSON and let the API do
it.
This hides any changes to the Elasticsearch low level protocol away
from my code.

On Nov 11, 1:58 pm, maverick mauricio.alar...@gmail.com wrote:

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Elasticsearch Platform — Find real-time answers at scale | Elastic...

Take a look tohttps://github.com/elasticsearch/elasticsearch/blob/master/modules/te...

lines 67-70

I'm doing via

client.admin()
.indices()
.putMapping(Requests.putMappingRequest(indexName)
.source(mappingSource)
.type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

Same goes for Dates. What is the preferred way to get dates into and
out of the Elasticsearch API.
I don't imagine having to use the SimpleDateFormat from java.text do
I?

On Nov 12, 9:09 am, Ronak Patel ronak2...@gmail.com wrote:

Some other questions related to the Java API:

Using the Java API, what is the preferred way to index a GeoPoint?

Is this not valid?

final Map<String, Object> sourceMap = new HashMap<String, Object>();
sourceMap.put("coordinate", new GeoPoint(event.getLatitudeDeg(),
event.getLongitudeDeg()));

On Nov 11, 5:11 pm, maverick mauricio.alar...@gmail.com wrote:

As far as I know this is the only way to set the mapping for an index,
is not that you're writing json on your own but instead using the java
API provided to do it.

Anybody wants to add her/his two cents here?

~M

On Nov 11, 2:55 pm, Ronak Patel ronak2...@gmail.com wrote:

So that means this API should not be used?
I would rather not have to deal with building JSON and let the API do
it.
This hides any changes to the Elasticsearch low level protocol away
from my code.

On Nov 11, 1:58 pm, maverick mauricio.alar...@gmail.com wrote:

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Elasticsearch Platform — Find real-time answers at scale | Elastic...

Take a look tohttps://github.com/elasticsearch/elasticsearch/blob/master/modules/te...

lines 67-70

I'm doing via

client.admin()
.indices()
.putMapping(Requests.putMappingRequest(indexName)
.source(mappingSource)
.type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

Yes, mappings can only be provided using their json representation, which
you can build however you want (read it from a file, build it using
your favorite json lib, or use elasticsearch XContent).

On Sat, Nov 12, 2011 at 12:11 AM, maverick mauricio.alarcon@gmail.comwrote:

As far as I know this is the only way to set the mapping for an index,
is not that you're writing json on your own but instead using the java
API provided to do it.

Anybody wants to add her/his two cents here?

~M

On Nov 11, 2:55 pm, Ronak Patel ronak2...@gmail.com wrote:

So that means this API should not be used?
I would rather not have to deal with building JSON and let the API do
it.
This hides any changes to the Elasticsearch low level protocol away
from my code.

On Nov 11, 1:58 pm, maverick mauricio.alar...@gmail.com wrote:

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Elasticsearch Platform — Find real-time answers at scale | Elastic.
..

Take a look tohttps://
github.com/elasticsearch/elasticsearch/blob/master/modules/te...

lines 67-70

I'm doing via

client.admin()
.indices()

.putMapping(Requests.putMappingRequest(indexName)

                                            .source(mappingSource)
                                            .type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what do
I use for the source Map? It lacks generics and as such, I'm confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel

GeoPoint will not help, its an internal class used in ES, not meant to
construct points to be indexed. Just build the structure you want to index
that maps to the document.

On Sat, Nov 12, 2011 at 4:09 PM, Ronak Patel ronak2121@gmail.com wrote:

Some other questions related to the Java API:

Using the Java API, what is the preferred way to index a GeoPoint?

Is this not valid?

final Map<String, Object> sourceMap = new HashMap<String, Object>();
sourceMap.put("coordinate", new
GeoPoint(event.getLatitudeDeg(),
event.getLongitudeDeg()));

On Nov 11, 5:11 pm, maverick mauricio.alar...@gmail.com wrote:

As far as I know this is the only way to set the mapping for an index,
is not that you're writing json on your own but instead using the java
API provided to do it.

Anybody wants to add her/his two cents here?

~M

On Nov 11, 2:55 pm, Ronak Patel ronak2...@gmail.com wrote:

So that means this API should not be used?
I would rather not have to deal with building JSON and let the API do
it.
This hides any changes to the Elasticsearch low level protocol away
from my code.

On Nov 11, 1:58 pm, maverick mauricio.alar...@gmail.com wrote:

Why don't you use the provided
org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder() class
and build the json source mapping based on

Elasticsearch Platform — Find real-time answers at scale | Elastic...

Take a look tohttps://
github.com/elasticsearch/elasticsearch/blob/master/modules/te...

lines 67-70

I'm doing via

client.admin()
.indices()

.putMapping(Requests.putMappingRequest(indexName)

.source(mappingSource)

                                            .type(type)

On Nov 11, 10:30 am, Ronak Patel ronak2...@gmail.com wrote:

Hello,

I'm trying to register a GeoPoint type with an embedded
Elasticsearch
node and am wondering what the correct API usage is.

I understand I have to use the PutMappingRequestBuilder...but what
do
I use for the source Map? It lacks generics and as such, I'm
confused
what I should add there.

final PutMappingRequestBuilder mappingRequestBuilder = new
PutMappingRequestBuilder(this.searchService.admin().indices());

Thanks,

Ronak Patel