Closed faizangulzar closed 2 years ago
This certainly isn't an issue with the package, since any queries you create just get passed through to the underlying ES client.
If I had to guess, then either random_score
should be an empty array []
and not an empty object {}
... or the ES client is converting the empty object to an empty array by mistake. Depending on how you build your query, you might be able to coerce the conversion properly?
Above is the query array before passing in package 'search' method
Elasticsearch::search($query);
"random_score": {
"seed": "1477072619038"
}
I used "seed" field under "random_score", now its giving random results.
Thankyou for you response, @cviebrock
It might be worth testing your query (without the explicit seed) using the native ES PHP client directly. If it doesn't work there (and I suspect it won't), then raise this as an issue with them: https://github.com/elastic/elasticsearch-php/issues
Not sure if this issue is any help, but it suggests using
'random_score' => new \StdClass()
instead of an empty array. Again, I suspect the official PHP client is serializing things unexpectedly.
When I search via "Postman", it returns random results every time because of using the "random_score" field in the search query. When I search using "cviebrock/laravel-elasticsearch" package in my laravel app, it returns an error :
Without the 'random_score' field, it works fine. But I wanted to get Randomly sorted results every time.
I am using :
Could anyone help me with this? I will be thankful!