Using Dynamic Mappings for language related Fields


(guilhermejkr) #1

Hello,
I have a system with multiple fields, some in English and some in Japanese,
I have installed a plugin and after a bit of help added the mapping and it
worked, however, since the mapping was for a specific field It would not
work when I queried for "_all" it did not work, I am trying to add a
dynamic mapping for it, as below, however, It is failing:

    XContentBuilder xbMapping =
            jsonBuilder()
                    .startObject()
                    .startObject("mappings")
                    .startObject(indexType)
                    .startObject("dynamic_templates")
                    .startObject("jp")
                    .field("match", "*")
                    .field("match_mapping_type", "string")
                    .startObject("mapping")
                    .field("type", "string")
                    .field("analyzer", JAPANESE_LANGUzzAGE_ANALYSIS)
                    .endObject()
                    .endObject()
                    .endObject()
                    .endObject()
                    .endObject();

             elasticSearchClient.admin().indices()
            .preparePutMapping(indexName)
            .setType(indexType)
            .setSource(xbMapping)
            .execute().get();

Any Ideas on what I am doing wrong? And if I add this mapping to "*" will I
still be able to perform queries without passing the analyser? or should I
use different types for each document I add depending on the language?

Thank you

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Jun Ohtani) #2

Hi

_all field is metadata field.
It uses the default analyzer to analyze its values.

This section will help you.
http://www.elastic.co/guide/en/elasticsearch/guide/current/root-object.html#all-field

And the following article, Dealing with Human Language, will help you to
deal with multi languages.
http://www.elastic.co/guide/en/elasticsearch/guide/current/language-intro.html

2015-05-04 0:26 GMT+09:00 guilhermejkr@gmail.com:

Hello,
I have a system with multiple fields, some in English and some in
Japanese, I have installed a plugin and after a bit of help added the
mapping and it worked, however, since the mapping was for a specific field
It would not work when I queried for "_all" it did not work, I am trying to
add a dynamic mapping for it, as below, however, It is failing:

    XContentBuilder xbMapping =
            jsonBuilder()
                    .startObject()
                    .startObject("mappings")
                    .startObject(indexType)
                    .startObject("dynamic_templates")
                    .startObject("jp")
                    .field("match", "*")
                    .field("match_mapping_type", "string")
                    .startObject("mapping")
                    .field("type", "string")
                    .field("analyzer", JAPANESE_LANGUzzAGE_ANALYSIS)
                    .endObject()
                    .endObject()
                    .endObject()
                    .endObject()
                    .endObject();

             elasticSearchClient.admin().indices()
            .preparePutMapping(indexName)
            .setType(indexType)
            .setSource(xbMapping)
            .execute().get();

Any Ideas on what I am doing wrong? And if I add this mapping to "*" will
I still be able to perform queries without passing the analyser? or should
I use different types for each document I add depending on the language?

Thank you

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--

Jun Ohtani
blog : http://blog.johtani.info

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPW8A5yR_SQo6dZpXm7FiGFtTwDbyAFC9dDiBYh_C-N_kKRREw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3