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
|
--TEST--
SolrDocument::sort - Sort Document fields
--FILE--
<?php
require_once "bootstrap.inc";
$doc = new SolrDocument();
$doc->addField('z1', 'z1val');
$doc->addField('z1', 'z1val2');
$doc->addField('z1', 'z1val3');
$doc->addField('id', 334455);
$doc->addField('cat', 'Software');
$doc->addField('cat', 'Lucene');
separator('unsorted');
print_r($doc->getFieldNames());
separator('field ASC');
$doc->sort(SolrDocument::SORT_FIELD_NAME, SolrDocument::SORT_ASC);
print_r($doc->getFieldNames());
separator('field DESC');
$doc->sort(SolrDocument::SORT_FIELD_NAME, SolrDocument::SORT_DESC);
print_r($doc->getFieldNames());
separator('value ASC');
$doc->sort(SolrDocument::SORT_FIELD_VALUE_COUNT, SolrDocument::SORT_ASC);
print_r($doc->getFieldNames());
separator('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
)
================================== value ASC ===================================
Array
(
[0] => id
[1] => cat
[2] => z1
)
================================== value DESC ==================================
Array
(
[0] => z1
[1] => cat
[2] => id
)
|