簡體   English   中英

使用Elasticsearch的Curl Exception 7 PHP和Guzzle

[英]Curl Exception 7 PHP and Guzzle with Elasticsearch

我正在嘗試使用php客戶端為使用Guzzle的彈性搜索索引文檔。 編譯完php腳本后,我得到一個錯誤,提示“內部服務器錯誤,代碼500”。進行一些研究后,這似乎是連接服務器的問題,但奇怪的是,我想做的所有事情都已設置好在同一台機器上。 我的Elasticsearch實例,我要索引的文檔以及php腳本都保存並在同一台機器上運行。 這是我的PHP腳本:

<?php
require '/home/aharmon/vendor/autoload.php';

$client = new Elasticsearch\Client();

$root = realpath('/home/aharmon/elkdata/for_elk_test_2014_11_24/Agencies');

$iter = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
    RecursiveIteratorIterator::SELF_FIRST,
    RecursiveIteratorIterator::CATCH_GET_CHILD);

$paths = array($root);
foreach ($iter as $path => $dir) {
if ($dir -> isDir()) {
    $paths[] = $path;
    }
}

//Create the index and mappings
$mapping['index'] = 'rvuehistoricaldocuments2009-2013'; //mapping code
$mapping['body'] = array (
'mappings' => array (
    'documents' => array (
        '_source' => array (
            'enabled' => true
        ),
        'properties' => array(
            'doc_name' => array(
                'type' => 'string',
                'analyzer' => 'standard'
            ),
            'description' => array(
                'type' => 'string'
            )
        )
    )
)
);






//Now index the documents
for ($i = 0; $i <= 10000; $i++) {
    $params ['body'] [] = array(
    'index' => array(
        '_id' => $i
        )
    );

    $params ['body'] [] = array(
    'type' => 'documents',
    'body' => array(
        'foo' => 'bar'//Document body goes here

        )
    );


//Every 1000 documents stop and send the bulk request.

if($i % 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);
}
}

$client ->indices()->create($mapping)
?>

如果有人以前看過此書或對什么問題有傾向,將不勝感激。 在嘗試設置SSH之前,我遇到了類似的問題,但是我已經配置了防火牆,並且SSH可以正常工作,所以我不確定為什么會這樣。

檢查此鏈接對我來說沒問題: http : //www.elastic.co/guide/zh-CN/elasticsearch/client/php-api/current/_index_operations.html#_put_mappings_api

 <?php // Set the index and type $params['index'] = 'my_index'; $params['type'] = 'my_type2'; // Adding a new type to an existing index $myTypeMapping2 = array( '_source' => array( 'enabled' => true ), 'properties' => array( 'first_name' => array( 'type' => 'string', 'analyzer' => 'standard' ), 'age' => array( 'type' => 'integer' ) ) ); $params['body']['my_type2'] = $myTypeMapping2; // Update the index mapping $client->indices()->putMapping($params); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM