Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Scout with Elastic search not working

I tried

  • Using Elastic search with Laravel scout with packages

    "laravel/scout": "^1.0",
    "tamayo/laravel-scout-elastic": "^1.0"
    
  • Ran Elasticsearch server in localhost:9200 and created index and gave necessary config's,

  • added searchable trait's to the model,

  • and imported data to index like

    php artisan scout:import "App\story"
    Imported [App\story] models up to ID: 4
    All [App\story] records have been imported.
    

But when I do a search it returns an empty array

 story::search("the")->get()
 => Illuminate\Database\Eloquent\Collection {#754
      all: [],
 }

when I do curl also it shows like,

// http://localhost:9200/author/_search?pretty=true&q=*:*

      {
        "took": 1,
        "timed_out": false,
        "_shards": {
          "total": 5,
          "successful": 5,
          "failed": 0
        },
        "hits": {
          "total": 0,
          "max_score": null,
          "hits": [
            
          ]
        }
      }

When I adding the record without index in ES the model throws an error like index not found. But after adding data and all, it seems empty. Did I miss anything?

The whole same works fine with algolia.

like image 418
Prakash Chokalingam Avatar asked Jan 04 '17 15:01

Prakash Chokalingam


2 Answers

Set QUEUE=sync or you could turn off queue on config/scout.php.

Had the same issue: https://github.com/ErickTamayo/laravel-scout-elastic/issues/43

like image 108
gabi doroftei Avatar answered Sep 24 '22 01:09

gabi doroftei


I had the same issue. Delete your index in Elasticsearch and run:

php artisan scout:import App\\story

Let scout create it.

like image 32
tacheshun Avatar answered Sep 26 '22 01:09

tacheshun