Skip to content

Commit 68a9580

Browse files
committed
Bug #72740 Improved tests
1 parent 3dbdb7e commit 68a9580

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

tests/bug_72740.phpt

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Solr Bug #72740 - addQueryField return wrong query
2+
Solr Bug #72740 - addPhraseField return wrong query
33
--SKIPIF--
44
<?php require_once 'skip.if.server_not_configured.inc'; ?>
55
--FILE--
@@ -23,11 +23,36 @@ $dismaxQuery->addPhraseField( "phraseField2", 5, 1 );
2323
$dismaxQuery->addSortField('score', SolrQuery::ORDER_DESC);
2424
$dismaxQuery->addSortField('manufacturedate_dt', SolrQuery::ORDER_DESC);
2525

26+
// Scenario 1: DisMax Query Parser - Adds Phrase Fields with both boost and slop.
27+
// Expect:
28+
// - pf parameter should list each phrase field with ~ and ^ prefix for slop and boost value respectively.
29+
$queryResponse = $client->query( $dismaxQuery );
30+
31+
print_r($queryResponse->getResponse()->responseHeader->params);
32+
33+
// Scenario 2: Same as Scenario 1, now including explicit query fields too.
34+
// Expect:
35+
// - pf parameter should list each phrase field with ~ and ^ prefix for slop and boost value respectively.
36+
// - qf parameter should list each query field with a trailing ^ (no boost here).
37+
$dismaxQuery->addQueryField('score');
38+
$dismaxQuery->addQueryField('manufacturedate_dt');
2639

2740
$queryResponse = $client->query( $dismaxQuery );
2841

2942
print_r($queryResponse->getResponse()->responseHeader->params);
3043

44+
// Scenario 3: Same as Scenario 2, now including explicit boost value for the query fields.
45+
// Expect:
46+
// - pf parameter should list each phrase field with ~ and ^ prefix for slop and boost value respectively.
47+
// - qf parameter should list each query field with a ^ prefix for boost value.
48+
$dismaxQuery->removeQueryField('score');
49+
$dismaxQuery->removeQueryField('manufacturedate_dt');
50+
$dismaxQuery->addQueryField('score', 3);
51+
$dismaxQuery->addQueryField('manufacturedate_dt', 7);
52+
53+
$queryResponse = $client->query( $dismaxQuery );
54+
55+
print_r($queryResponse->getResponse()->responseHeader->params);
3156
?>
3257
--EXPECTF--
3358
SolrObject Object
@@ -39,4 +64,26 @@ SolrObject Object
3964
[sort] => score desc,manufacturedate_dt desc
4065
[version] => 2.2
4166
[wt] => xml
67+
)
68+
SolrObject Object
69+
(
70+
[q] => *:*
71+
[defType] => edismax
72+
[indent] => on
73+
[qf] => score^ manufacturedate_dt^
74+
[pf] => phraseField1~5^10 phraseField2~1^5
75+
[sort] => score desc,manufacturedate_dt desc
76+
[version] => 2.2
77+
[wt] => xml
78+
)
79+
SolrObject Object
80+
(
81+
[q] => *:*
82+
[defType] => edismax
83+
[indent] => on
84+
[qf] => score^3 manufacturedate_dt^7
85+
[pf] => phraseField1~5^10 phraseField2~1^5
86+
[sort] => score desc,manufacturedate_dt desc
87+
[version] => 2.2
88+
[wt] => xml
4289
)

0 commit comments

Comments
 (0)