0

I am learning my ways around Elasticsearch. And I did index some documents, but then realized that I wanted to attach a specific analyzer to them.

But when I try to run "putMappings" command - it says Mapper for [short_summary] conflicts with existing mapping in other types. As explained in this answer I can't change mappings on the existing field.

So that leaves me with only one option - to re-index documetns with analyzer set. But how do I do that?

The only code I made up is this:

$doc = ['short_summary' = '...text...'];

$params = [
    'index' => 'index_name',
    'type' => 'document_type',
    'id' => $doc_id,
    'body' => $doc,
];

$es_client->index($params);

Do you know the proper way to set the analyzer upon indexing a new document?

Dmitriy Lezhnev
  • 801
  • 2
  • 10
  • 18
  • I think you would need to: make a new index (with the new analizer etc), add documents to it, then make an alias to point to your new index (the actual switch won't be noticed by the users let's say). – ka_lin May 31 '17 at 12:14
  • I guess, this is a code sample with most full index creation request possible: https://github.com/elastic/elasticsearch-php/blob/27e051e18d4a0f126f99e168ce011971c91eafec/docs/index-operations.asciidoc#create-an-index-advanced-example It includes mappings, settings etc. – Dmitriy Lezhnev May 31 '17 at 13:24

0 Answers0