I have a problem about bulk indexing.
I have created analysis and mapping, but this error is appear when I try to bulk indexing my data.
What is the problem with my code?
Elasticsearch_error
object(Elasticsearch\Common\Exceptions\UnexpectedValueException)[321]
protected 'message' => string '"id" is not a valid parameter. Allowed parameters are: "consistency", "refresh", "replication", "type", "client", "custom"' (length=122)
private 'string' (Exception) => string '' (length=0)
protected 'code' => int 0
protected 'file' => string 'D:\xampp\htdocs\lisento\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Endpoints\AbstractEndpoint.php' (length=107)
protected 'line' => int 245
private 'trace' (Exception) =>
array (size=21)
0 =>
array (size=6)
'file' => string 'D:\xampp\htdocs\lisento\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Endpoints\AbstractEndpoint.php' (length=107)
'line' => int 97
'function' => string 'checkUserParams' (length=15)
'class' => string 'Elasticsearch\Endpoints\AbstractEndpoint' (length=40)
'type' => string '->' (length=2)
'args' =>
array (size=1)
0 =>
array (size=1)
'id' => string '1234567890' (length=10)
AbstractEndpoint.php
private function checkUserParams($params)
{
if (isset($params) !== true) {
return; //no params, just return.
}
$whitelist = array_merge($this->getParamWhitelist(), array('client', 'custom'));
foreach ($params as $key => $value) {
if (array_search($key, $whitelist) === false) {
throw new UnexpectedValueException(sprintf(
'"%s" is not a valid parameter. Allowed parameters are: "%s"',
$key,
implode('", "', $whitelist)
));
}
}
}
My_mapping
[
"mappings" => [
"twitter" => [
"properties" => [
"tweet_id" => [ "type" => "long" ],
"tweet_text" => [
"type" => "string",
"fields" => [
"raw" => [ "type" => "string", "index" => "no" ],
"text" => [ "type" => "string", "analyzer" => "tweet_text_autocomp_analyzer" ],
"std" => [ "type" => "string", "analyzer" => "tweet_text_std_analyzer" ]
],
],
"tweet_date" => ["type" => "date","format" => "Y-M-d H:m:s" ],
"favorited_count" => [ "type" => "integer" ],
"retweet_count" => [ "type" => "integer" ],
"place" => [ "type" => "string" ],
"url" => [ "type" => "string" ],
"hashtags" => [
"type" => "nested",
"fields" => [
"hashtag" => [ "type" => "string" ]
],
],
"campaign_id" => [ "type" => "long" ],
"user_id" => [ "type" => "long" ],
"screen_name" => [ "type" => "string" ]
]
]
]
]
My_data
{
"user_id": 117093939,
"screen_name": "",
"campaign_id": "1234567890",
"tweet_id": 609287367120150000,
"tweet_text": "Oberyn's scattered skull #GameOfThronesFood",
"tweet_date": "2015-06-12 16:13:22",
"favorited_count": 0,
"retweet_count": 0,
"url": ""
},
{
"user_id": 491504312,
"screen_name": "",
"campaign_id": "1234567890",
"tweet_id": 609287361751610000,
"tweet_text": "RT @alex_backes: Buffalo Wildlings #GameOfThronesFood @midnight",
"tweet_date": "2015-06-12 16:13:21",
"favorited_count": 0,
"retweet_count": 43,
"url": ""
},
{
"user_id": 745355136,
"screen_name": "",
"campaign_id": "1234567890",
"tweet_id": 609287345951610000,
"tweet_text": "RT @CMPunk: Jon snow cones! @midnight #GameOfThronesFood",
"tweet_date": "2015-06-12 16:13:17",
"favorited_count": 0,
"retweet_count": 203,
"url": ""
}
}
My_bulk_code
for ($j = 0; $j <= $i; $j++) {
$params ['body'][] = array(
'index' => array(
'index' => $appconfig['ES_INDEX'],
'type' => $index["type"],
'_id' => $j,
'body' => $index["docs"]
),
);
// Every 1000 documents stop and send the bulk request
if ($j % 1000) {
$responses = $client->bulk($params);
// erase the old bulk request
$params = array();
// unset the bulk response when you are done to save memory
unset($responses);
}
}
here is the answer. https://github.com/elastic/elasticsearch-php/issues/247 it works fine.