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

Automatic reindexing not working ? #100

Open
prigal opened this issue Jul 23, 2015 · 1 comment
Open

Automatic reindexing not working ? #100

prigal opened this issue Jul 23, 2015 · 1 comment

Comments

@prigal
Copy link

prigal commented Jul 23, 2015

I add the

use \Iverberk\Larasearch\Traits\SearchableTrait;

on my Product model.

Then I do a

$product= new Product(['title'=>'Amazing']);
$product->save();

Then I try to search via :

curl -XGET 'http://127.0.0.1:9200/products_20150722092624/_search?pretty=1&q=Amazing'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

Why the index wasn't updated after save() to make 'Amazing' searchable ? Do I forgot to do something ?

Thank you.

@smithdp1
Copy link

i has same problem. this is what i did.

To fix auto index for larasearch find around line 25 in:
/vendor/larasearch/src/Iverberk/Larasearch/Observer.php

         /**
     * Model save event handler
     *
     * @param Model $model
     */
    public function saved(Model $model)
    {
        if ($model::$__es_enable && $model->shouldIndex())
        {
            Queue::push('Iverberk\Larasearch\Jobs\ReindexJob', $this->findAffectedModels($model));
        }
    }

Change to:

         /**
     * Model save event handler
     *
     * @param Model $model
     */
    public function saved(Model $model)
    {

            Queue::push('Iverberk\Larasearch\Jobs\ReindexJob', $this->findAffectedModels($model));

    }

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