Skip to content

Commit 6bdb4cd

Browse files
Add cancellable and execution limit params (solariumphp#1136)
Co-authored-by: Markus Kalkbrenner <git@kalki.de>
1 parent 70d4d08 commit 6bdb4cd

File tree

14 files changed

+593
-116
lines changed

14 files changed

+593
-116
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- PHP 8.4 support
10-
- Solarium\Core\Query\AbstractQuery::setCpuAllowed()
10+
- Solarium\QueryType\Select\Query\Quey::setCanCancel()
11+
- Solarium\QueryType\Select\Query\Quey::setQueryUuid()
12+
- Solarium\QueryType\Select\Query\Quey::setPartialResults()
13+
- Solarium\QueryType\Select\Query\Quey::setCpuAllowed()
14+
- Solarium\QueryType\Select\Query\Quey::setMemAllowed()
15+
- Solarium\QueryType\Select\Query\Quey::setSegmentTerminateEarly()
16+
- Solarium\QueryType\Select\Query\Quey::setMultiThreaded()
1117

1218
### Fixed
1319
- JSON update requests correctly handle `Stringable` object set as field value
@@ -18,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1824
### Removed
1925
- Support for config objects, you have to convert them to an array before passing to a constructor or `setOptions()`
2026

27+
### Deprecated
28+
- Solarium\Core\Query\AbstractQuery::setTimeAllowed(), moved to Solarium\QueryType\Select\Query\Query
2129

2230
## [6.3.5]
2331
### Added

docs/queries/select-query/building-a-select-query/building-a-select-query.md

+24-16
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@ Options
55

66
The options below can be set as query option values, but also by using the set/get methods. See the API docs for all available methods.
77

8-
| Name | Type | Default value | Description |
9-
|----------------------|------------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
10-
| handler | string | select | Name of the Solr request handler to use, without leading or trailing slashes |
11-
| resultclass | string | Solarium\_Result\_Select | Classname for result. If you set a custom classname make sure the class is readily available (or through autoloading) |
12-
| documentclass | string | Solarium\_Document\_ReadWrite | Classname for documents in the resultset. If you set a custom classname make sure the class is readily available (or through autoloading) |
13-
| query | string | \*:\* | Query to execute |
14-
| start | int | 0 | Start position (offset) in the complete Solr query resultset, to paginate big resultsets. |
15-
| rows | integer | 10 | Number of rows to fetch, starting from the 'start' (offset) position. It's a limit, you might get less. |
16-
| fields | string | - ,score | Comma separated list of fields to fetch from Solr. There are two special values: '\*' meaning 'all fields' and 'score' to also fetch the Solr document score value. |
17-
| sort | array | empty array | Array with sort field as key and sort order as values. Multiple entries possible, they are used in the order of the array. Example: array('price' =&gt; 'asc') |
18-
| querydefaultoperator | string | null | With a null value the default of your Solr config will be used. If you want to override this supply 'AND' or 'OR' as the value. |
19-
| querydefaultfield | string | null | With a null value the default of your Solr config will be used. If you want to override this supply a field name as the value. |
20-
| responsewriter | string | json | You can set this to 'phps' for improved response parsing performance, at the cost of a (possible) security risk. Only use 'phps' for trusted Solr instances. |
21-
| tag | array of strings | null | You can supply one or multiple tags for the main query string, to allow for exclusion of the main query in facets |
22-
| cursormark | string | null | Set to '\*' and make sure sort contains a uniqueKey field to enable cursor functionality when passing the query to the PrefetchIterator plugin. Available since Solr 4.7. |
23-
| splitonwhitespace | bool | null | Specifies whether the query parser splits the query text on whitespace before it's sent to be analyzed. Available for 'lucene' and 'edismax' query parsers since Solr 6.5. |
8+
| Name | Type | Default value | Description |
9+
|-----------------------|------------------|-----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
10+
| handler | string | select | Name of the Solr request handler to use, without leading or trailing slashes |
11+
| resultclass | string | Solarium\\QueryType\\Select\\Result\\Document | Classname for result. If you set a custom classname make sure the class is readily available (or through autoloading) |
12+
| documentclass | string | Solarium\\QueryType\\Select\\Result\\Result | Classname for documents in the resultset. If you set a custom classname make sure the class is readily available (or through autoloading) |
13+
| query | string | \*:\* | Query to execute |
14+
| start | int | 0 | Start position (offset) in the complete Solr query resultset, to paginate big resultsets. |
15+
| rows | integer | 10 | Number of rows to fetch, starting from the 'start' (offset) position. It's a limit, you might get less. |
16+
| cancancel | bool | null | Is this a cancellable query? |
17+
| queryuuid | string | null | Custom UUID to identify a cancellable query with |
18+
| fields | string | \*,score | Comma separated list of fields to fetch from Solr. There are two special values: '\*' meaning 'all fields' and 'score' to also fetch the Solr document score value. |
19+
| sort | array | empty array | Array with sort field as key and sort order as values. Multiple entries possible, they are used in the order of the array. Example: array('price' =&gt; 'asc') |
20+
| querydefaultoperator | string | null | With a null value the default of your Solr config will be used. If you want to override this supply 'AND' or 'OR' as the value. |
21+
| querydefaultfield | string | null | With a null value the default of your Solr config will be used. If you want to override this supply a field name as the value. |
22+
| responsewriter | string | json | You can set this to 'phps' for improved response parsing performance, at the cost of a (possible) security risk. Only use 'phps' for trusted Solr instances. |
23+
| tag | array of strings | null | You can supply one or multiple tags for the main query string, to allow for exclusion of the main query in facets |
24+
| partialresults | bool | null | If set to false, reaching a query execution limit will generate an exception instead of returning partial results |
25+
| timeallowed | int | null | Amount of time, in milliseconds, allowed for a search to complete |
26+
| cpuallowed | int | null | Amount of CPU time, in milliseconds, allowed for a search to complete |
27+
| memallowed | float | null | Amount of memory, in MiB, allowed for a search thread to allocate during query execution |
28+
| segmentterminateearly | bool | null | If set to true, the search may be terminated early within a segment |
29+
| multithreaded | bool | null | Controls if Solr may use more than one thread to satisfy the request |
30+
| cursormark | string | null | Set to '\*' and make sure sort contains a uniqueKey field to enable cursor functionality when passing the query to the PrefetchIterator plugin. Available since Solr 4.7. |
31+
| splitonwhitespace | bool | null | Specifies whether the query parser splits the query text on whitespace before it's sent to be analyzed. Available for 'lucene' and 'edismax' query parsers since Solr 6.5. |
2432
||
2533

2634
Examples

docs/queries/select-query/result-of-a-select-query/result-of-a-select-query.md

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ Solr status code. This is not the HTTP status code! The normal value for success
1111

1212
Solr index query time. This doesn't include things like the HTTP response time. Only available if your Solr server sends headers (`omitHeader=false`).
1313

14+
### PartialResults
15+
16+
Solr sets this flag if partial results are returned because an execution limit is reached. Only available if your Solr server sends headers (`omitHeader=false`).
17+
18+
### SegmentTerminatedEarly
19+
20+
Solr sets this flag if early segment termination happens. Only available if your Solr server sends headers (`omitHeader=false`).
21+
1422
### NumFound
1523

1624
Total number of documents that matched the query. This is not necessarily the same as the number of document in the resultset, depending on you query settings!

src/Core/Query/AbstractQuery.php

+4-24
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public function getResultClass(): ?string
9898
* @param int $value
9999
*
100100
* @return self Provides fluent interface
101+
*
102+
* @deprecated Will be removed in Solarium 7. This parameter is only relevant for Select queries.
101103
*/
102104
public function setTimeAllowed(int $value): self
103105
{
@@ -110,36 +112,14 @@ public function setTimeAllowed(int $value): self
110112
* Get timeAllowed option.
111113
*
112114
* @return int|null
115+
*
116+
* @deprecated Will be removed in Solarium 7. This parameter is only relevant for Select queries.
113117
*/
114118
public function getTimeAllowed(): ?int
115119
{
116120
return $this->getOption('timeallowed');
117121
}
118122

119-
/**
120-
* Set cpuAllowed option.
121-
*
122-
* @param int $value
123-
*
124-
* @return self Provides fluent interface
125-
*/
126-
public function setCpuAllowed(int $value): self
127-
{
128-
$this->setOption('cpuallowed', $value);
129-
130-
return $this;
131-
}
132-
133-
/**
134-
* Get cpuAllowed option.
135-
*
136-
* @return int|null
137-
*/
138-
public function getCpuAllowed(): ?int
139-
{
140-
return $this->getOption('cpuallowed');
141-
}
142-
143123
/**
144124
* Set omitHeader option.
145125
*

src/Core/Query/AbstractRequestBuilder.php

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public function build(AbstractQuery $query): Request
3838
$request->setHandler($query->getHandler());
3939
$request->addParam('distrib', $query->getDistrib());
4040
$request->addParam('omitHeader', $query->getOmitHeader());
41-
$request->addParam('timeAllowed', $query->getTimeAllowed());
42-
$request->addParam('cpuAllowed', $query->getCpuAllowed());
4341
$request->addParam('NOW', $query->getNow());
4442
$request->addParam('TZ', $query->getTimeZone());
4543
$request->addParam('ie', $query->getInputEncoding());

0 commit comments

Comments
 (0)