[ckan-dev] Preventing CKAN Search Error when Solr special characters are included

Adrià Mercader adria.mercader at okfn.org
Tue Mar 6 09:45:19 UTC 2018


Hi Brian,

I'm not seeing this in more recent CKAN versions (
https://demo.ckan.org/dataset?q=doi%3Asome_doi), so the first thing to try
would be to upgrade CKAN to the latest patch release (2.5.7) [1]. This is
really important regardless to have all latest patches, and it should be
really easy.

The second thing would be to upgrade Solr, which would be good to do
anyway. The approach would be to just install the new Solr version, apply
the CKAN schema, point CKAN to it and just reindex the datasets again. Any
Solr version included in your OS package manager is likely to be more
recent than that, but installing a more modern version like 6.6.x is quite
straightforward if you follow the official instructions [2] (Don't use Solr
7.x as it hasn't been fully tested with CKAN yet)

If that doesn't help, the `before_search()` method of the
`IPackageController` interface [3] allows you to modify the query
parameters sent to Solr from within your extension. You could use it to
quote any search term containing "doi:", or apply any other more complex
logic that you want.


Hope this helps! If not do let us know

Adrià


[1]
http://docs.ckan.org/en/latest/maintaining/upgrading/upgrade-package-to-patch-release.html
[2] https://lucene.apache.org/solr/guide/6_6/installing-solr.html +
https://lucene.apache.org/solr/guide/6_6/taking-solr-to-production.html#taking-solr-to-production
[3]
http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IPackageController.before_search


On 6 March 2018 at 00:18, Brian Bonnlander <bonnland at ucar.edu> wrote:

>
> Hi everyone,
>
> We've had a number of CKAN users try to search for strings like "doi:" on
> our CKAN instance.   This is the typical prefix for a Digital Object
> Identifier, which is becoming more common for Digital Assets.
>
>
> It looks like when this string is not in double-quotes, CKAN treats this
> as a solr query for a field named "doi", which does not exist.
>
> And the user gets back an error message:
>
> "There was an error while searching. Please try again."
>
> Or sometimes we also get back:
>
> "An internal server error occurred"
>
>
> We're wondering if there is a way to change either our CKAN or Solr
> configuration, so that any text typed by the user will be treated as a text
> string to search for, rather than a potential Solr query.   This would be
> the equivalent of always surrounding the string with double-quotes, but
> without the user's awareness.
>
> We're using CKAN 2.5.2 with Solr 1.4 ( <--  old version, but I haven't
> found much documentation on how to upgrade).   The Solr query parser is the
> default "lucene" parser.
>
>
> Any guidance or help would be greatly appreciated!
>
>
> Thanks,
>
> --Brian
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20180306/1f81968f/attachment-0003.html>


More information about the ckan-dev mailing list