[MarkLogic Dev General] Sorting the search results depending on
the elements if available
andrew.j.welch at gmail.com
Thu Jan 28 02:57:28 PST 2010
You just list the things to order by in the order by clause, seperated
by a comma:
order by $first, $second
It's designed to work exactly as you need.
On 27 January 2010 21:30, Anurag Saxena <anurag24k at gmail.com> wrote:
> I am executing the search query which returns the result and now i need to
> sort them on the basis of condition.......
> i need to order by the result if element abc exists in the documents of
> result set, if it dose not exists in the document of result set then order
> by xyz element if it is available in the document.
> What it means is i have to sort the result set on the basis of first element
> and if it dose not exists then i have to do the sorting on another element.
> below scenarios can be available in the data/result set of search.....
> 1. Document may have only first element
> 2. Document may have only second element
> 3. document may have both the elements
> 4. document may have none of the element
> So sorting should be done on the preference of first element if it is
> available and if not available then sorting should be done on another
> It means my final output should have sorted result set mixed on the basis of
> first and second element on the basis of their respective availability.
> Can some body please help me out here (how to achieve the expected behavior)
> if you have done it earlier or faced the same situation.
> Also what would be the behavior of document which do not have any of the
> element for ascending and descending condition. means will they come in
> first or last always?
> you can assume that my search is working perfectly fine and i just need to
> add the order by clause.
> General mailing list
> General at developer.marklogic.com
More information about the General