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

No data imported after scout:import #83

Open
booni3 opened this issue Feb 7, 2020 · 6 comments
Open

No data imported after scout:import #83

booni3 opened this issue Feb 7, 2020 · 6 comments

Comments

@booni3
Copy link

booni3 commented Feb 7, 2020

I am sure I am just missing something here but just cannot get any data to import into elasticsearch. I am using 7.0.1 with the latest version of your package and have installed into a fresh Laravel install to ensure nothing else was interfering.

Steps To Reproduce

  1. Install fresh version of Laravel (v6.13.1)
  2. Create posts model/migration and seed with 1000 rows.
  3. Install matchish/laravel-scout-elasticsearch, publish config, add service provider.
  4. update config and env as below.
return [
    'host' => env('ELASTICSEARCH_HOST'),
    'indices' => [
        'mappings' => [
            'default' => [
                'properties' => [
                    'id' => [
                        'type' => 'keyword',
                    ]
                ],
            ],
            'posts' => [
                'properties' => [
                    'id' => ['type' => 'keyword'],
                    'name' => ['type' => 'text'],
                ],
            ],
        ],
        'settings' => [
            'default' => [
                'number_of_shards' => 1,
                'number_of_replicas' => 0,
            ],
        ],
    ],
];

image

  1. add searchable to post model as below.
class Post extends Model
{
    use Searchable;

    protected $fillable = [
        'name'
    ];

    public function searchableAs()
    {
        return 'posts';
    }
}
  1. Install elastic search with docker at v7.0.1

  2. php artisan scout:import - this shows me 100% and 6/6 imported. I assume the 6/6 is the rows imported? I have 1000 rows seeded in the database however.

image

  1. Check elasticsearch via Dejavu. I see the mappings were correctly set but it shows no data:

image

@booni3
Copy link
Author

booni3 commented Feb 7, 2020

That always happens... work on an issue for hours and post for help and then immediately solve it!

Turns out you need to actually publish the scout service provider. I generally don't publish the configs as most seem to work when left in the vendor. Seems not in this case!

@booni3 booni3 closed this as completed Feb 7, 2020
@matchish
Copy link
Owner

matchish commented Feb 8, 2020

@booni3 Actually you are right at some point, it's better when a package works after composer install without config. In case of Elasticsearch I can't imagine application without customizing config but yes it will be better if the package works without publishing the config.

@booni3
Copy link
Author

booni3 commented Feb 8, 2020

@mackhankins - I am glad you partly agree, and thanks for such a fast reply!

But actually in this case my issue was with the Scout config that was not published. I am not sure if its the combination of scout and this package that causes the issue or if scout has just been designed to required the config to be published. Will need to investigate further.

Side note; This is my first experience with elastic search and so far I am impressed. I hope I will be able to contribute at some point to this package!

@booni3 booni3 reopened this Mar 18, 2020
@booni3
Copy link
Author

booni3 commented Mar 18, 2020

I have just upgraded to the latest version and I seem to have the above issue again on Local development. On our AWS server, there is no issue, but locally when running an import or adding new records to the DB we do not see any records within elastic search.

My setup is:

  • v4 of this package
  • php 7.4.3
  • Laravel 7.2.0
  • OSx running Valet
  • Docker elastic search instance

When running an import we get:

  • Index created with correct mappings
  • No records are created
  • If we have an error in our mapping an exception is thrown as expected. Otherwise, we have no exceptions thrown during import or record creation.

I have checked my installation, cleared cache/config etc.

Has anything changed around the service provider issue as above or anything else around local development setup?

@matchish
Copy link
Owner

Now config from vendor will be merged by default if you publish ElasticSearchServiceProvider. Did you publish elasticsearch provider?

@matchish
Copy link
Owner

matchish commented Mar 20, 2020

I think maybe it's better to autoload it also by default. And if someone wants to override it, he can do it app service provider.

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

2 participants