Skip to content

Commit 73e0a55

Browse files
Add cancellable and execution limit params
1 parent 1955d16 commit 73e0a55

File tree

10 files changed

+407
-100
lines changed

10 files changed

+407
-100
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

+3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ The options below can be set as query option values, but also by using the set/g
1313
| query | string | \*:\* | Query to execute |
1414
| start | int | 0 | Start position (offset) in the complete Solr query resultset, to paginate big resultsets. |
1515
| 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 |
1618
| 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. |
1719
| 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' => 'asc') |
1820
| 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. |
1921
| 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. |
2022
| 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. |
2123
| 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 |
2225
| 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. |
2326
| 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. |
2427
||

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());

src/QueryType/Select/Query/Query.php

+215-19
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,34 @@ public function getResponseParser(): ?ResponseParserInterface
205205
return new ResponseParser();
206206
}
207207

208+
/**
209+
* Set a custom document class.
210+
*
211+
* This class should implement the document interface
212+
*
213+
* @param string $value classname
214+
*
215+
* @return self Provides fluent interface
216+
*/
217+
public function setDocumentClass(string $value): self
218+
{
219+
$this->setOption('documentclass', $value);
220+
221+
return $this;
222+
}
223+
224+
/**
225+
* Get the current documentclass option.
226+
*
227+
* The value is a classname, not an instance
228+
*
229+
* @return string|null
230+
*/
231+
public function getDocumentClass(): ?string
232+
{
233+
return $this->getOption('documentclass');
234+
}
235+
208236
/**
209237
* Set default query operator.
210238
*
@@ -280,55 +308,75 @@ public function getStart(): ?int
280308
}
281309

282310
/**
283-
* Set a custom document class.
284-
*
285-
* This class should implement the document interface
311+
* Set the number of rows to fetch.
286312
*
287-
* @param string $value classname
313+
* @param int $rows
288314
*
289315
* @return self Provides fluent interface
290316
*/
291-
public function setDocumentClass(string $value): self
317+
public function setRows(int $rows): self
292318
{
293-
$this->setOption('documentclass', $value);
319+
$this->setOption('rows', $rows);
294320

295321
return $this;
296322
}
297323

298324
/**
299-
* Get the current documentclass option.
325+
* Get the number of rows.
300326
*
301-
* The value is a classname, not an instance
327+
* @return int|null
328+
*/
329+
public function getRows(): ?int
330+
{
331+
return $this->getOption('rows');
332+
}
333+
334+
/**
335+
* Set the canCancel option.
302336
*
303-
* @return string|null
337+
* @param bool $canCancel
338+
*
339+
* @return self Provides fluent interface
304340
*/
305-
public function getDocumentClass(): ?string
341+
public function setCanCancel(bool $canCancel): self
306342
{
307-
return $this->getOption('documentclass');
343+
$this->setOption('cancancel', $canCancel);
344+
345+
return $this;
308346
}
309347

310348
/**
311-
* Set the number of rows to fetch.
349+
* Get the canCancel option.
312350
*
313-
* @param int $rows
351+
* @return bool|null
352+
*/
353+
public function getCanCancel(): ?bool
354+
{
355+
return $this->getOption('cancancel');
356+
}
357+
358+
/**
359+
* Set the queryUUID option.
360+
*
361+
* @param string $queryUuid
314362
*
315363
* @return self Provides fluent interface
316364
*/
317-
public function setRows(int $rows): self
365+
public function setQueryUuid(string $queryUuid): self
318366
{
319-
$this->setOption('rows', $rows);
367+
$this->setOption('queryuuid', $queryUuid);
320368

321369
return $this;
322370
}
323371

324372
/**
325-
* Get the number of rows.
373+
* Get the queryUUID option.
326374
*
327-
* @return int|null
375+
* @return string|null
328376
*/
329-
public function getRows(): ?int
377+
public function getQueryUuid(): ?string
330378
{
331-
return $this->getOption('rows');
379+
return $this->getOption('queryuuid');
332380
}
333381

334382
/**
@@ -779,6 +827,154 @@ public function setTags(array $tags): self
779827
return $this;
780828
}
781829

830+
/**
831+
* Set the partialResults option.
832+
*
833+
* @param bool $partialResults
834+
*
835+
* @return self Provides fluent interface
836+
*/
837+
public function setPartialResults(bool $partialResults): self
838+
{
839+
$this->setOption('partialresults', $partialResults);
840+
841+
return $this;
842+
}
843+
844+
/**
845+
* Get the partalResults option.
846+
*
847+
* @return bool|null
848+
*/
849+
public function getPartialResults(): ?bool
850+
{
851+
return $this->getOption('partialresults');
852+
}
853+
854+
/**
855+
* Set timeAllowed option.
856+
*
857+
* @param int $value
858+
*
859+
* @return self Provides fluent interface
860+
*
861+
* @not-deprecated
862+
*/
863+
public function setTimeAllowed(int $value): self
864+
{
865+
$this->setOption('timeallowed', $value);
866+
867+
return $this;
868+
}
869+
870+
/**
871+
* Get timeAllowed option.
872+
*
873+
* @return int|null
874+
*
875+
* @not-deprecated
876+
*/
877+
public function getTimeAllowed(): ?int
878+
{
879+
return $this->getOption('timeallowed');
880+
}
881+
882+
/**
883+
* Set cpuAllowed option.
884+
*
885+
* @param int $value
886+
*
887+
* @return self Provides fluent interface
888+
*/
889+
public function setCpuAllowed(int $value): self
890+
{
891+
$this->setOption('cpuallowed', $value);
892+
893+
return $this;
894+
}
895+
896+
/**
897+
* Get cpuAllowed option.
898+
*
899+
* @return int|null
900+
*/
901+
public function getCpuAllowed(): ?int
902+
{
903+
return $this->getOption('cpuallowed');
904+
}
905+
906+
/**
907+
* Set memAllowed option.
908+
*
909+
* @param float $value
910+
*
911+
* @return self Provides fluent interface
912+
*/
913+
public function setMemAllowed(float $value): self
914+
{
915+
$this->setOption('memallowed', $value);
916+
917+
return $this;
918+
}
919+
920+
/**
921+
* Get memAllowed option.
922+
*
923+
* @return float|null
924+
*/
925+
public function getMemAllowed(): ?float
926+
{
927+
return $this->getOption('memallowed');
928+
}
929+
930+
/**
931+
* Set the segmentTerminateEarly option.
932+
*
933+
* @param bool $segmentTerminateEarly
934+
*
935+
* @return self Provides fluent interface
936+
*/
937+
public function setSegmentTerminateEarly(bool $segmentTerminateEarly): self
938+
{
939+
$this->setOption('segmentterminateearly', $segmentTerminateEarly);
940+
941+
return $this;
942+
}
943+
944+
/**
945+
* Get the segmentTerminateEarly option.
946+
*
947+
* @return bool|null
948+
*/
949+
public function getSegmentTerminateEarly(): ?bool
950+
{
951+
return $this->getOption('segmentterminateearly');
952+
}
953+
954+
/**
955+
* Set the multiThreaded option.
956+
*
957+
* @param bool $multiThreaded
958+
*
959+
* @return self Provides fluent interface
960+
*/
961+
public function setMultiThreaded(bool $multiThreaded): self
962+
{
963+
$this->setOption('multithreaded', $multiThreaded);
964+
965+
return $this;
966+
}
967+
968+
/**
969+
* Get the multiThreaded option.
970+
*
971+
* @return bool|null
972+
*/
973+
public function getMultiThreaded(): ?bool
974+
{
975+
return $this->getOption('multithreaded');
976+
}
977+
782978
/**
783979
* Set the cursor mark to fetch.
784980
*

0 commit comments

Comments
 (0)