Elasticquent icon indicating copy to clipboard operation
Elasticquent copied to clipboard

Sorting

Open stevepop opened this issue 10 years ago • 4 comments

Hi adamfairholm, thanks for providing this package. It gave me quite a quick entry into using Elasticsearch and Laravel compared to using Symfony 2 and Elastica which took me longer to wrap my head around.

In the documentation, under searching, you listed the parameters to the searchByQuery method and the last one was sort. I have however gone through your code and seen that the last parameter is offset and there is nowhere in the code where sorting is implemented. Is this an omission? How can I pass a sort query to elasticsearch via Elasticquent?

Thanks Steve

stevepop avatar Jan 25 '15 15:01 stevepop

Here is where in the code it should happen:

https://github.com/adamfairholm/Elasticquent/blob/4d16e2df77449d75058231b92bdc3aab92bb87ec/src/ElasticquentTrait.php#L262

yswery avatar Jan 29 '15 21:01 yswery

what's the param for sort? string 'asc' or 'desc'? because none of them work.

subdesign avatar May 28 '15 12:05 subdesign

You need to pass through thr ElasticSearch sort params.

Example: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html

yswery avatar May 28 '15 21:05 yswery

Appreciate the info. I tried '{"sort":[{"id" : {"order" : "asc"}},"_score"]}' only to get search_parse_exception: No mapping found. Would someone assist in the correct format? Thanks.

fusion52 avatar Mar 17 '16 20:03 fusion52