1--TEST--
2SolrInputDocument::sort - Sort Document fields
3--FILE--
4<?php
5
6require_once "bootstrap.inc";
7$doc = new SolrInputDocument();
8
9
10$doc->addField('z1', 'z1val', 1);
11$doc->addField('z1', 'z1val2');
12$doc->addField('z1', 'z1val3');
13
14$doc->addField('id', 334455, 2);
15$doc->addField('cat', 'Software', 3);
16$doc->addField('cat', 'Lucene');
17
18printf("---------------- %s --------------------\n", 'unsorted');
19print_r($doc->getFieldNames());
20
21printf("---------------- %s --------------------\n", 'field ASC');
22$doc->sort(SolrDocument::SORT_FIELD_NAME, SolrDocument::SORT_ASC);
23print_r($doc->getFieldNames());
24printf("---------------- %s --------------------\n", 'field DESC');
25$doc->sort(SolrDocument::SORT_FIELD_NAME, SolrDocument::SORT_DESC);
26print_r($doc->getFieldNames());
27printf("---------------- %s --------------------\n", 'boost ASC');
28$doc->sort(SolrDocument::SORT_FIELD_BOOST_VALUE, SolrDocument::SORT_ASC);
29print_r($doc->getFieldNames());
30printf("---------------- %s --------------------\n", 'boost DESC');
31$doc->sort(SolrDocument::SORT_FIELD_BOOST_VALUE, SolrDocument::SORT_DESC);
32print_r($doc->getFieldNames());
33
34printf("---------------- %s --------------------\n", 'value ASC');
35$doc->sort(SolrDocument::SORT_FIELD_VALUE_COUNT, SolrDocument::SORT_ASC);
36print_r($doc->getFieldNames());
37printf("---------------- %s --------------------\n", 'value DESC');
38$doc->sort(SolrDocument::SORT_FIELD_VALUE_COUNT, SolrDocument::SORT_DESC);
39print_r($doc->getFieldNames());
40?>
41--EXPECT--
42---------------- unsorted --------------------
43Array
44(
45    [0] => z1
46    [1] => id
47    [2] => cat
48)
49---------------- field ASC --------------------
50Array
51(
52    [0] => cat
53    [1] => id
54    [2] => z1
55)
56---------------- field DESC --------------------
57Array
58(
59    [0] => z1
60    [1] => id
61    [2] => cat
62)
63---------------- boost ASC --------------------
64Array
65(
66    [0] => z1
67    [1] => id
68    [2] => cat
69)
70---------------- boost DESC --------------------
71Array
72(
73    [0] => cat
74    [1] => id
75    [2] => z1
76)
77---------------- value ASC --------------------
78Array
79(
80    [0] => id
81    [1] => cat
82    [2] => z1
83)
84---------------- value DESC --------------------
85Array
86(
87    [0] => z1
88    [1] => cat
89    [2] => id
90)
91