Skip to content

Commit

Permalink
Add cancellable and execution limit params (#1136)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Kalkbrenner <[email protected]>
  • Loading branch information
thomascorthals and mkalkbrenner authored Nov 27, 2024
1 parent 70d4d08 commit 6bdb4cd
Show file tree
Hide file tree
Showing 14 changed files with 593 additions and 116 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- PHP 8.4 support
- Solarium\Core\Query\AbstractQuery::setCpuAllowed()
- Solarium\QueryType\Select\Query\Quey::setCanCancel()
- Solarium\QueryType\Select\Query\Quey::setQueryUuid()
- Solarium\QueryType\Select\Query\Quey::setPartialResults()
- Solarium\QueryType\Select\Query\Quey::setCpuAllowed()
- Solarium\QueryType\Select\Query\Quey::setMemAllowed()
- Solarium\QueryType\Select\Query\Quey::setSegmentTerminateEarly()
- Solarium\QueryType\Select\Query\Quey::setMultiThreaded()

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

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

## [6.3.5]
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ Options

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.

| Name | Type | Default value | Description |
|----------------------|------------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| handler | string | select | Name of the Solr request handler to use, without leading or trailing slashes |
| resultclass | string | Solarium\_Result\_Select | Classname for result. If you set a custom classname make sure the class is readily available (or through autoloading) |
| 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) |
| query | string | \*:\* | Query to execute |
| start | int | 0 | Start position (offset) in the complete Solr query resultset, to paginate big resultsets. |
| rows | integer | 10 | Number of rows to fetch, starting from the 'start' (offset) position. It's a limit, you might get less. |
| 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. |
| 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') |
| 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. |
| 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. |
| 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. |
| 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 |
| 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. |
| 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. |
| Name | Type | Default value | Description |
|-----------------------|------------------|-----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| handler | string | select | Name of the Solr request handler to use, without leading or trailing slashes |
| 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) |
| 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) |
| query | string | \*:\* | Query to execute |
| start | int | 0 | Start position (offset) in the complete Solr query resultset, to paginate big resultsets. |
| rows | integer | 10 | Number of rows to fetch, starting from the 'start' (offset) position. It's a limit, you might get less. |
| cancancel | bool | null | Is this a cancellable query? |
| queryuuid | string | null | Custom UUID to identify a cancellable query with |
| 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. |
| 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') |
| 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. |
| 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. |
| 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. |
| 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 |
| partialresults | bool | null | If set to false, reaching a query execution limit will generate an exception instead of returning partial results |
| timeallowed | int | null | Amount of time, in milliseconds, allowed for a search to complete |
| cpuallowed | int | null | Amount of CPU time, in milliseconds, allowed for a search to complete |
| memallowed | float | null | Amount of memory, in MiB, allowed for a search thread to allocate during query execution |
| segmentterminateearly | bool | null | If set to true, the search may be terminated early within a segment |
| multithreaded | bool | null | Controls if Solr may use more than one thread to satisfy the request |
| 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. |
| 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. |
||

Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Solr status code. This is not the HTTP status code! The normal value for success

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

### PartialResults

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`).

### SegmentTerminatedEarly

Solr sets this flag if early segment termination happens. Only available if your Solr server sends headers (`omitHeader=false`).

### NumFound

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!
Expand Down
28 changes: 4 additions & 24 deletions src/Core/Query/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public function getResultClass(): ?string
* @param int $value
*
* @return self Provides fluent interface
*
* @deprecated Will be removed in Solarium 7. This parameter is only relevant for Select queries.
*/
public function setTimeAllowed(int $value): self
{
Expand All @@ -110,36 +112,14 @@ public function setTimeAllowed(int $value): self
* Get timeAllowed option.
*
* @return int|null
*
* @deprecated Will be removed in Solarium 7. This parameter is only relevant for Select queries.
*/
public function getTimeAllowed(): ?int
{
return $this->getOption('timeallowed');
}

/**
* Set cpuAllowed option.
*
* @param int $value
*
* @return self Provides fluent interface
*/
public function setCpuAllowed(int $value): self
{
$this->setOption('cpuallowed', $value);

return $this;
}

/**
* Get cpuAllowed option.
*
* @return int|null
*/
public function getCpuAllowed(): ?int
{
return $this->getOption('cpuallowed');
}

/**
* Set omitHeader option.
*
Expand Down
2 changes: 0 additions & 2 deletions src/Core/Query/AbstractRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public function build(AbstractQuery $query): Request
$request->setHandler($query->getHandler());
$request->addParam('distrib', $query->getDistrib());
$request->addParam('omitHeader', $query->getOmitHeader());
$request->addParam('timeAllowed', $query->getTimeAllowed());
$request->addParam('cpuAllowed', $query->getCpuAllowed());
$request->addParam('NOW', $query->getNow());
$request->addParam('TZ', $query->getTimeZone());
$request->addParam('ie', $query->getInputEncoding());
Expand Down
Loading

0 comments on commit 6bdb4cd

Please sign in to comment.