File: 020.solrdocument_update_field.phpt

package info (click to toggle)
php-solr 2.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,620 kB
  • sloc: ansic: 14,274; xml: 1,313; php: 1,239; pascal: 11; makefile: 3
file content (90 lines) | stat: -rw-r--r-- 2,313 bytes parent folder | download | duplicates (3)
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::updateField
--FILE--
<?php

require_once 'bootstrap.inc';

$doc = new SolrInputDocument();

$doc->addField('id', 1123);

$doc->updateField('field1', SolrInputDocument::UPDATE_MODIFIER_ADD, 'val1');
$doc->updateField('field2_s', SolrInputDocument::UPDATE_MODIFIER_SET, 'val2');
$doc->updateField('field3_i', SolrInputDocument::UPDATE_MODIFIER_INC, 5);
$doc->updateField('field1', SolrInputDocument::UPDATE_MODIFIER_REMOVE, 'val0');
$doc->updateField('field1', SolrInputDocument::UPDATE_MODIFIER_REMOVEREGEX, '[\d]{2}/[\d]{2}/[\d]{4}');

try {
	$doc->updateField('arr2', 6, 'not gonna happen');
} catch (SolrIllegalArgumentException $e) {
	print_exception($e);
}

try {
	$doc->updateField('arr3', 0, 'not gonna happen');
} catch (SolrIllegalArgumentException $e) {
	print_exception($e);
}

print_r($doc->toArray());

?>
--EXPECT--
SolrIllegalArgumentException 4003: Invalid field value modifier.
SolrIllegalArgumentException 4003: Invalid field value modifier.
Array
(
    [document_boost] => 0
    [field_count] => 4
    [fields] => Array
        (
            [0] => SolrDocumentField Object
                (
                    [name] => id
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => 1123
                        )

                )

            [1] => SolrDocumentField Object
                (
                    [name] => field1
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => val1
                            [1] => val0
                            [2] => [\d]{2}/[\d]{2}/[\d]{4}
                        )

                )

            [2] => SolrDocumentField Object
                (
                    [name] => field2_s
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => val2
                        )

                )

            [3] => SolrDocumentField Object
                (
                    [name] => field3_i
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => 5
                        )

                )

        )

)