{"action":"created","issue":{"url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/29","labels_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/29/comments","events_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/29/events","html_url":"https://github.com/jarektkaczyk/eloquence/issues/29","id":109832063,"number":29,"title":"OrderBy in searchable query builder not working as expected","user":{"login":"andynoelker","id":4426398,"avatar_url":"https://avatars.githubusercontent.com/u/4426398?v=3","gravatar_id":"","url":"https://api.github.com/users/andynoelker","html_url":"https://github.com/andynoelker","followers_url":"https://api.github.com/users/andynoelker/followers","following_url":"https://api.github.com/users/andynoelker/following{/other_user}","gists_url":"https://api.github.com/users/andynoelker/gists{/gist_id}","starred_url":"https://api.github.com/users/andynoelker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andynoelker/subscriptions","organizations_url":"https://api.github.com/users/andynoelker/orgs","repos_url":"https://api.github.com/users/andynoelker/repos","events_url":"https://api.github.com/users/andynoelker/events{/privacy}","received_events_url":"https://api.github.com/users/andynoelker/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-05T16:07:31Z","updated_at":"2015-10-05T19:20:22Z","closed_at":"2015-10-05T16:43:12Z","body":"If I insert an `orderBy()` into a searchable query, the data returned is still ordered by relevance first, and only applies the ordering within groups of results with the same relevance.\r\n\r\nFor instance, let's take a basic searchable query:\r\n\r\n```\r\nItem::search('test')->orderBy('name')->get()\r\n```\r\n\r\nExpected output:\r\n\r\n```\r\n[\r\n    { name: 'A Item', relevance: 4 }\r\n    { name: 'B Item', relevance: 8 }\r\n    { name: 'C Item', relevance: 4 }\r\n    { name: 'D Item', relevance: 8 }\r\n]\r\n```\r\n\r\nActual output:\r\n\r\n```\r\n[\r\n    { name: 'B Item', relevance: 8 }\r\n    { name: 'D Item', relevance: 8 }\r\n    { name: 'A Item', relevance: 4 }\r\n    { name: 'C Item', relevance: 4 }\r\n]\r\n```\r\n\r\nIt still sorts by relevance first before applying the `orderBy()`. This makes it impossible to sort results alphabetically. If you wanted to order by the relevance and something else then you could always add an `orderBy('relevance')` into your query, but I don't think this should be forced in if another orderBy statement exists. Can this be fixed easily?"},"comment":{"url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/comments/145637282","html_url":"https://github.com/jarektkaczyk/eloquence/issues/29#issuecomment-145637282","issue_url":"https://api.github.com/repos/jarektkaczyk/eloquence/issues/29","id":145637282,"user":{"login":"jarektkaczyk","id":6928818,"avatar_url":"https://avatars.githubusercontent.com/u/6928818?v=3","gravatar_id":"","url":"https://api.github.com/users/jarektkaczyk","html_url":"https://github.com/jarektkaczyk","followers_url":"https://api.github.com/users/jarektkaczyk/followers","following_url":"https://api.github.com/users/jarektkaczyk/following{/other_user}","gists_url":"https://api.github.com/users/jarektkaczyk/gists{/gist_id}","starred_url":"https://api.github.com/users/jarektkaczyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarektkaczyk/subscriptions","organizations_url":"https://api.github.com/users/jarektkaczyk/orgs","repos_url":"https://api.github.com/users/jarektkaczyk/repos","events_url":"https://api.github.com/users/jarektkaczyk/events{/privacy}","received_events_url":"https://api.github.com/users/jarektkaczyk/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T19:20:22Z","updated_at":"2015-10-05T19:20:22Z","body":"I never intended to use searchable functionality this way, but I can see where you're coming from.\r\n\r\nIt doesn't require any hard work to make it happen, so create a PR with a test."}}