-
Notifications
You must be signed in to change notification settings - Fork 381
VUFIND-1210: Use Solr JSON APIs #4991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
48a8396
caae5eb
8e80568
e82a8e9
27c2e6d
2a56ef9
f6d550a
e35bfe1
6206ef4
5db7650
09be7e1
2f2d089
d943442
9451ac2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,7 @@ public function onSearchPre(EventInterface $event) | |
| if (!isset($parts[1])) { | ||
| continue; | ||
| } | ||
| // TODO This will need some config changes to know how to nest | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pending #5013 first. |
||
| $params->add(urldecode($parts[0]), urldecode($parts[1])); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
|
|
||
| use VuFindSearch\Backend\Solr\Command\RawJsonSearchCommand; | ||
| use VuFindSearch\ParamBag; | ||
| use VuFindSearch\ParamBagBag; | ||
|
|
||
| use function count; | ||
| use function floatval; | ||
|
|
@@ -249,15 +250,18 @@ public function performRequest($recordId) | |
|
|
||
| // prepare search params | ||
| $params = $this->getParams()->getBackendParameters(); | ||
| $params->set('spellcheck', 'false'); | ||
| $explainParams = new ParamBag([ | ||
| 'fl' => 'id,score', | ||
| 'facet' => 'true', | ||
| 'debug' => 'true', | ||
| 'indent' => 'true', | ||
| 'param' => 'q', | ||
| 'echoParams' => 'all', | ||
| 'explainOther' => 'id:"' . addcslashes($recordId, '"') . '"', | ||
| $params = ParamBagBag::from($params); | ||
| $params->setNested('params', 'spellcheck', 'false'); | ||
| $explainParams = new ParamBagBag([ | ||
| 'fields' => 'id,score', | ||
| 'facet' => 'true', // This field will need an update when I do the facet API upgrade | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Waiting on #5017 |
||
| 'params' => new ParamBag([ | ||
| 'debug' => 'true', | ||
| 'indent' => 'true', | ||
| 'param' => 'query', // Is this change correct? | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Waiting on #5017 |
||
| 'echoParams' => 'all', | ||
| 'explainOther' => 'id:"' . addcslashes($recordId, '"') . '"', | ||
| ]), | ||
| ]); | ||
| $params->mergeWith($explainParams); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ | |
| use Laminas\EventManager\EventInterface; | ||
| use Laminas\EventManager\SharedEventManagerInterface; | ||
| use VuFindSearch\Backend\BackendInterface; | ||
| use VuFindSearch\ParamBag; | ||
| use VuFindSearch\ParamBagBag; | ||
| use VuFindSearch\Service; | ||
|
|
||
| use function in_array; | ||
|
|
@@ -126,28 +128,37 @@ public function onSearchPre(EventInterface $event) | |
| $command = $event->getParam('command'); | ||
| if ($command->getTargetIdentifier() === $this->backend->getIdentifier()) { | ||
| $params = $command->getSearchParameters(); | ||
| $params = ParamBagBag::from($params); | ||
| $allShardsContexts = ['retrieve', 'retrieveBatch']; | ||
| if (in_array($command->getContext(), $allShardsContexts)) { | ||
| // If we're retrieving by id(s), we should pull all shards to be | ||
| // sure we find the right record(s). | ||
| $params->set('shards', implode(',', $this->shards)); | ||
| $params->setNested('params', 'shards', implode(',', $this->shards)); | ||
| } else { | ||
| // In any other context, we should make sure our field values are | ||
| // all legal. | ||
|
|
||
| // Normalize array of strings containing comma-separated values to | ||
| // simple array of values; check if $params->get('shards') returns | ||
| // an array to prevent invalid argument warnings. | ||
| $shards = $params->get('shards'); | ||
| $shards = $params->getNested('params', 'shards'); | ||
| $shards = explode( | ||
| ',', | ||
| implode(',', (is_array($shards) ? $shards : [])) | ||
| ); | ||
| $fields = $this->getFields($shards); | ||
| $specs = $this->getSearchSpecs($fields); | ||
| $this->backend->getQueryBuilder()->setSpecs($specs); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic below is just a first draft, I don't like how it breaks the ParamBag abstraction completely in order to use array_filter. Either have to build some sort of filtering into ParamBag itself or just create a new ParamBag on the fly instead. Also, I will need assistance actually testing this with shards. |
||
| $facets = $params->get('facet.field') ?: []; | ||
| $params->set('facet.field', array_diff($facets, $fields)); | ||
| if ($params->get('facet')) { | ||
| $facets = $params->get('facet')[0]->getArrayCopy(); | ||
| $facets = array_filter( | ||
| $facets, | ||
| fn ($facet) => | ||
| (!($facet[0] instanceof ParamBag)) | ||
| || !in_array($facet[0]->getArrayCopy()['field'][0], $fields) | ||
| ); | ||
| $params->set('facet', new ParamBag($facets)); | ||
| } | ||
| } | ||
| } | ||
| return $event; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the TreeDataSource changes are tested yet; I don't have hierarchy data.