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