basemkhirat/elasticsearch

Only run one bulk

Opened this issue · 0 comments

my config

<?php
return [
    # Here you can define the default connection name.

    'default'=>env('ELASTIC_CONNECTION', 'default'),

# Here you can define your connections.

    'connections'=>[
        'default'=>[
            'servers'=>[
                [
                    "host"=>env("ELASTIC_HOST", "127.0.0.1"),
                    "port"=>env("ELASTIC_PORT", 9200),
                    'user'=>env('ELASTIC_USER', ''),
                    'pass'=>env('ELASTIC_PASS', ''),
                    'scheme'=>env('ELASTIC_SCHEME', 'http'),
                ]
            ],

            // Custom handlers
            // 'handler' => new MyCustomHandler(),
            'index'=>env('ELASTIC_INDEX', 'orders')
        ]
    ],


    /**
     * es为兼容后期版本,一个index最多有一个type
     */
    'indices'=>[
        //index
        'orders'=>[
            'settings'=>[
                "number_of_shards"=>1,
                "number_of_replicas"=>0,
                'max_result_window'=>50000,//
            ],
            'mappings'=>[
                //type->orders
                'orders'=>[
                    'properties'=>[
                        'id'=>[
                            'type'=>'keyword',
                        ],
                        'username'=>[
                            'type'=>'keyword',
                        ],
                        'phone'=>[
                            'type'=>'keyword',
                        ],
                    ]
                ],
            ]
        ],
        //index
        'product_public'=>[
            'settings'=>[
                "number_of_shards"=>1,
                "number_of_replicas"=>0,
            ],
            'mappings'=>[
                //type->products
                'products'=>[
                    'properties'=>[
                        'product_code'=>[
                            'type'=>'keyword',
                        ],
                        'product_name'=>[
                            'type'=>'text'
                        ],
                    ]
                ]
            ]
        ]
    ]
];

first create index
image

then I want add two tables' data to elasticsearch

  $orders=Order::query()->get(['id', 'username', 'phone'])->toArray();
        $this->info('order count is'.count($orders));;
        ES::index('orders')->type("orders")->bulk($orders);
        dump('orders added');//Don't run  
        $products=ProductPublic::query()->get(['product_code', 'product_name'])->toArray();
        $this->info('product count is'.count($products));;
        ES::index('product_public')->type("products")->bulk($products);
        dump('product add');

after run

image

image

index of product_public is empty?

elasticsearch vsersion is 6.8.1

composer.json
"basemkhirat/elasticsearch": "^1.4",