ErickTamayo / laravel-scout-elastic

Elastic Driver for Laravel Scout
MIT License
916 stars 242 forks source link

index not found exception #155

Closed Naveedali1234 closed 3 years ago

Naveedali1234 commented 3 years ago

Hi :)

i have installed this package and i did import my products table records but whenever i search anything then i am getting "index not found exception". below is my configuration of scout.php file

`'elasticsearch' => [

    'index' => env('ELASTICSEARCH_INDEX', 'marketplace'),

    'hosts' => [
        env('ELASTICSEARCH_HOST', 'http://localhost:9200'),
    ],
],`

when i did curl 'localhost:9200/marketplace/_mapping?pretty', then i got the following response.

`{

  "error" : {

"root_cause" : [ {

  "type" : "index_not_found_exception",

  "reason" : "no such index",

  "resource.type" : "index_or_alias",

  "resource.id" : "marketplace",

  "index" : "marketplace"

} ],

"type" : "index_not_found_exception",

"reason" : "no such index",

"resource.type" : "index_or_alias",

"resource.id" : "marketplace",

"index" : "marketplace"

  },

  "status" : 404

}`

Am i missing something in there? any help would be really appreciated.

mlambley commented 3 years ago

Ensure that you're doing a php artisan scout:import \App\Models\Product

Then the index would be something like marketplaceproducts

To list all indices, use GET /_cat/indices/

mlambley commented 3 years ago

When debugging, I add this code to the performRequest function in vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php:

\Illuminate\Support\Facades\Log::debug($endpoint->getMethod());
\Illuminate\Support\Facades\Log::debug($endpoint->getURI());
\Illuminate\Support\Facades\Log::debug(var_export($endpoint->getParams(), true));
\Illuminate\Support\Facades\Log::debug(var_export($endpoint->getBody(), true));
\Illuminate\Support\Facades\Log::debug(var_export($endpoint->getOptions(), true));

Then in one window I do less storage/logs/laravel.log while in another window I do:

php artisan tinker
\App\Models\Product::search('text');

And then in the logs it shows me exactly what is queried from elasticsearch.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.