简体   繁体   English

Elasticsearch批量索引错误消息:%s%不是有效参数。 允许的参数为:%s%

[英]Elasticsearch Bulk Indexing Error Message : %s% is not a valid parameter. Allowed parameters are: %s%

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 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 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 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);
    }
}           

You must check that the value of the param is not empty. 您必须检查参数的值不为空。 When the value is empty, you will get a malformed data that will cause this error. 当该值为空时,您将获得格式错误的数据,这将导致此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP Elasticsearch批量索引问题:“ 0”不是有效参数。 允许的参数是……” - PHP Elasticsearch Bulk Index Issue: “”0“ is not a valid parameter. Allowed parameters are …” ElasticSearch-带有刷新的批量索引 - ElasticSearch - Bulk Indexing with refresh 使用FSriver的Elasticsearch批量文件索引 - Elasticsearch Bulk File indexing with FSriver 在PHP中,imagepng()接受过滤器参数。 这些过滤器如何影响函数的输出? - In PHP, imagepng() accepts a filter parameter. How do these filters affect the function's output? 由于 PHP 7.3 `array_unshift()` 只能用一个参数调用。 重点是什么? - Since PHP 7.3 `array_unshift()` can be called with only one parameter. What's the point? Elasticsearch无法解析异常-批量索引 - Elasticsearch failed to parse exception— bulk indexing “配置文件”不是有效的参数-Elasticsearch - “profile” is not a valid parameter - Elasticsearch php curl soap 错误,<faultcode> soap:客户端</faultcode>无法处理没有有效操作参数的请求。 请提供有效的 soap action.r - php curl soap error, <faultcode>soap:Client</faultcode> Unable to handle request without a valid action parameter. Please supply a valid soap action.r ElasticSearch 2.1“ aggs”不是有效的参数 - ElasticSearch 2.1 “aggs” is not a valid parameter Facebook错误“缺少redirect_uri参数。” - Facebook error “Missing redirect_uri parameter.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM