Hey, you may want to use index templates to make sure, that you do not have to check this stuff inside of your application and can just rely that the mappign is configured as expected, see
See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html --Alex On Sat, Feb 8, 2014 at 10:51 PM, Ryan Chazen <[email protected]> wrote: > OK Nevermind, I see how it's meant to be done now: > > On app start, check if the index exists already: if it doesn't create it > with the correct mappings > If it does, retrieve the mappings and compare. If they're wrong, update it > with a putmapping with the correct mappings. > > I'd guess that doing the mapping compares during data insert would be very > slow and it's why the API is set up this way. Makes sense. > > So only one question: is the "retrieve mappings and compare" step > necessary? If I always putmapping with the correct mappings, will it just > do nothing if they're already correct? > > > > On Saturday, February 8, 2014 11:30:56 PM UTC+2, Ryan Chazen wrote: >> >> Hey >> >> I'm inserting some documents using >> >> Map<String, Object> map = new HashMap<>(); >> map.put("field1", "something"); >> ... >> client.prepareIndex("a", "a").setSource(map).get(); >> >> >> This inserts field1 as a text field with an analyzed index, but it's not >> actually text, just a string id or other data field. This is inside an ORM, >> so I'd like to have it set to use a not analyzed index automatically when >> inserting the data. >> I can't seem to find anything in the API for defining the mapping when >> indexing. Have I missed something? I'd prefer not to have to run a special >> mapping query after inserting the data as it would slow the ORM down to be >> constantly checking if indexes are analyzed or not... >> >> >> -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/f890caf7-00ae-4f16-8e7b-e5ea1833a23a%40googlegroups.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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9dVqEzjzOLgLR920O7s3QpO6R1bNGAPpH2X4qK4%3DXhJA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
