John Davidson

php - Laravel scout elastic-scout-driver return empty response

0 comments
Message:


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,
];
}



My Answer:
It looks like your search query in the tinker command might be incorrect. Instead of using 'title:Neque', try using just 'Neque' as the search term.

Try running the following command in tinker:

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


This should return the search results for the term 'Neque' in the title field of your events index.

If this still returns an empty collection, double check your indexing process and make sure that the data is being indexed correctly in Elasticsearch. You can also try reindexing your data to see if that resolves the issue.

Rate this post

5 of 5 based on 5538 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us