-
Notifications
You must be signed in to change notification settings - Fork 399
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
Using multi indcies/types to search #108
base: master
Are you sure you want to change the base?
Conversation
Can someone post an example of using this model. If you have to map multiple types of search results into models. Kind regards, |
Just in case if you have to provide APIs such as "search anything" or "I don't know anything but the keyword" |
@garveen Thank you for your reply. Yes this is what I want. There are multiple types i.e books, author and users, etc. Its kind of global search. Currently, I am using ElasticquentClientTrait directly to get the search results. But I want the results to be transformed into respective Eloquent models or some how I can parse the results into Transformers I have written using this library http://fractal.thephpleague.com/transformers/. For API consistency. This is my current code ` $params['body']['from'] = ($page - 1)*$paginate; $searchResults = $client->search($params); // this is manually being Transformed. |
In this case, my code will be: class Search extends \Illuminate\Database\Eloquent\Model
{
use \Elasticquent\ElasticquentTrait;
}
$results = Search::searchByQuery([...]);
// $results contains instances, and they are have been transformed.
foreach($results as $result) {
//...
} |
@garveen thank you man... I will give it go and let you know how it goes. |
@garveen I have found the limitation of the above approach is that Search::searchByQuery looks for type |
@jgardezi Oh it should be |
Refs:
https://www.elastic.co/guide/en/elasticsearch/guide/current/multi-index-multi-type.html
\Elasticsearch\Endpoints\AbstractEndpoint@setIndex
\Elasticsearch\Endpoints\AbstractEndpoint@setType
ElasticquentTrait.php has breaking change: The old data can NOT be searched until the indices be rebuilt.