Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only run one bulk #119

Open
dishcheng opened this issue Jun 18, 2020 · 0 comments
Open

Only run one bulk #119

dishcheng opened this issue Jun 18, 2020 · 0 comments

Comments

@dishcheng
Copy link

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",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant