Laravel scout elastic-scout-driver return empty response

Viewed 84

I trying to setup search functionality for Laravel app with elastic-scout-driver.

Events index is populated and i can get results with curl, but when i use search function i get empty response.

Curl:

 curl -X GET "localhost:9200/events/_search?pretty&q=title:Neque"  

{
  "_index" : "events",
  "_type" : "_doc",
  "_id" : "1ebdd7fb-c681-6db4-be79-1e00ea1e483a",
  "_score" : 4.683097,
  "_source" : {
     "id" : "1ebdd7fb-c681-6db4-be79-1e00ea1e483a",
     "title" : "Event Neque nostrum maxime fugiat."
     }
  }

Tinker:

>>> App\Event::search('title:Neque')->get();
=> Illuminate\Database\Eloquent\Collection {#5437
     all: [],
   }
>>> 

Event model


public function searchableAs()
{
    return 'events';
}

public function toSearchableArray()
    {
        return [
            'id' => $this->uuid,
            'title' => $this->title,
        ];
    }

1 Answers

Looks like all right, except you need to wrap searchable text in parentheses, like so:

App\Event::search('title:(Neque)')->get();
Related