Index Operations


#1

I am currently trying to make setting in my index just like below

PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "type": "edge_ngram",
          "min_gram": 1,
          "max_gram": "20"
        }
      }
    }
  }
}   

What should I modify in the php file so that I can apply the above setting in my index?

require 'vendor/autoload.php';

//$set=$_PUT['p'];

//set host
$hosts =['my_host'];

//
$client = Elasticsearch\ClientBuilder::create()->setHosts($hosts)->build();

// Set the index
$params = [
    'index' => 'my_index',
        'body' => [
            'settings' => [
                'analysis' =>
                    'my_analyzer': [ 
                        'type'=>'edge_ngram',
                        'min_gram'=> 1,
                        'max_gram'=> 20
                        ]
                    ],
                ]
    ];

$response = $client->indices()->putSettings($params);
echo $response;

(Adrien Grand) #2

Not very familiar with the PHP client but the difference seems to be here. I suspect this is calling the PUT my_index/_settings endpoint rather than PUT my_index. There is probably another function that allows you to call PUT my_index.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.