Manipulate Mapping from Java


(ildella) #1

Hi. I just started using ES and I need to create a simple interface to
manage indexes on different product I am developing using the same
backend that deal with ES.

I'm having this problem understanding how to pass the json code I find
in the doc to Java API to generate the request, like:

IndicesAdminClient indices = client.admin().indices();
String snowball = "{analysis: { analyzer: { default: { type:
snowball }}}}";
PutMappingRequest source =
Requests.putMappingRequest("artworks").source(snowball);
PutMappingResponse actionGet =
indices.putMapping(source).actionGet();

is not working cause the snowball String is incorrect. I've really no
idea how that String is supposed to be formatted and
I've watched here:
http://www.elasticsearch.org/guide/reference/index-modules/analysis/

but I can't find a prooper doc for my problem.

I am also a little confused about how to tell ES to index my fields.
Let's suppose that in the "artworks" index I have "artwork" document
type. With that command, given a proper String as source, I Can expect
all the field of artwork document type to be analysed with the
snowball filter?

Thanks.


(K.B.) #2

you need to pass the " with the config strings, e.g:

type: snowball -> type: "snowball"

Best

On 18 Mrz., 19:43, della ilde...@gmail.com wrote:

Hi. I just started using ES and I need to create a simple interface to
manage indexes on different product I am developing using the same
backend that deal with ES.

I'm having this problem understanding how to pass the json code I find
in the doc to Java API to generate the request, like:

IndicesAdminClient indices = client.admin().indices();
String snowball = "{analysis: { analyzer: { default: { type:
snowball }}}}";
PutMappingRequest source =
Requests.putMappingRequest("artworks").source(snowball);
PutMappingResponse actionGet =
indices.putMapping(source).actionGet();

is not working cause the snowball String is incorrect. I've really no
idea how that String is supposed to be formatted and
I've watched here:http://www.elasticsearch.org/guide/reference/index-modules/analysis/

but I can't find a prooper doc for my problem.

I am also a little confused about how to tell ES to index my fields.
Let's suppose that in the "artworks" index I have "artwork" document
type. With that command, given a proper String as source, I Can expect
all the field of artwork document type to be analysed with the
snowball filter?

Thanks.


(system) #3