{"issue":{"user":{"id":1036505,"login":"daniel2d2art","url":"https://api.github.com/users/daniel2d2art","avatar_url":"https://secure.gravatar.com/avatar/9beb366f8d50bf04052194919d02a929?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"9beb366f8d50bf04052194919d02a929"},"milestone":null,"title":"Default order_by scope ","created_at":"2011-12-18T12:53:47Z","updated_at":"2011-12-21T16:07:10Z","labels":[],"state":"closed","id":2593301,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/Casecommons/pg_search/issues/22","closed_at":"2011-12-21T16:07:10Z","number":22,"body":"By default pg_search sets \"pg_search_rank\" and \"id\" in order_by query. \r\n\r\n ORDER BY pg_search_rank DESC, \"product\".\"id\" ASC\r\n\r\nIf you plug custom order, this scopes over default pg_search order, like:\r\n\r\n ORDER BY pg_search_rank DESC, \"product\".\"id\" ASC, price ASC, updated_at DESC\r\n\r\nIMO, it's best to exclude \"id\" for the default pg_search order query. This lets plug custom orders based first on \"pg_search_rank\" order criteria and following the custom order. But default incluing \"id\", breaks the order priorities.\r\n\r\nAs you know, we can reset the default order using \"reorder\", but I think it's better that pg_search defaults order query will be only by \"pg_search_rank\" and exclude \"id\" \r\n\r\nRegards\r\n\r\n\r\n","url":"https://api.github.com/repos/Casecommons/pg_search/issues/22","comments":1,"assignee":null},"comment":{"user":{"id":2488,"login":"nertzy","url":"https://api.github.com/users/nertzy","avatar_url":"https://secure.gravatar.com/avatar/602f1b8ccf99dc47c43da83d53b4ffd5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"602f1b8ccf99dc47c43da83d53b4ffd5"},"created_at":"2011-12-21T16:07:10Z","updated_at":"2011-12-21T16:07:10Z","id":3235550,"body":"You can also use the (as of yet undocumented) `:order_within_rank` option to specify how to rank results that tie in a given search.\r\n\r\n    :order_within_rank => \"price ASC, updated_at DESC\"\r\n\r\ngives you\r\n\r\n    ORDER BY pg_search_rank DESC, price ASC, updated_at DESC\r\n\r\n    \r\n\r\nAs for the default, it is necessary if users want pagination to be consistent, so that's why I think it makes sense to keep it even though it won't be ideal for all users. ","url":"https://api.github.com/repos/Casecommons/pg_search/issues/comments/3235550"},"action":"created"}