Solr: Frequently asked questions
Where to find general information about Solr?
If you are interested in Solr in general the Solr wiki is a good starting point: http://wiki.apache.org/solr/. OpenCms specific topics are covered by this documentation.
How is Solr integrated in general?
Independent from OpenCms a standard Solr Server offers a HTTP-Interface that is reachable at http://localhost:8983/solr/select
in a default Apache Solr Installation.
You are able to attach each valid Solr query to this URL. The HTTP response can either be JSON or XML. For example, the answer of the query http://localhost:8983/solr/select?q=*:*&rows=2
could look like:
How to sort text for specific languages?
In this example, text is sorted according to the default German rules provided by Java. The rules for sorting German in Java are defined in a package called Java Locale.
Locales are typically defined as a combination of language and country, but you can specify just the language if you want. For example, if you specify "de" as the language, you will get sorting that works well for German language. If you specify "de" as the language and "CH" as the country, you will get German sorting specifically tailored for Switzerland. You can see a list of supported Locales here. And in order to get more general information about how text analysis is working with Solr have a look at Language Analysis page.
<!-- define a field type for German collation -->
<fieldType name="collatedGERMAN" class="solr.TextField">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.CollationKeyFilterFactory"
language="de"
strength="primary"
/>
</analyzer>
</fieldType>
...
<!-- define a field to store the German collated manufacturer names -->
<field name="manuGERMAN" type="collatedGERMAN" indexed="true" stored="false" />
...
<!-- copy the text to this field. We could create French, English, Spanish versions too,
-- and sort differently for different users!
-->
<copyField source="manu" dest="manuGERMAN"/>
Solr result size gets limited to 50 by default, how to get more than 50 results?
In order to return only permission checked resources (what is an expensive task) we only return this limited number of results. For paging over results please have a look at at the Solr parameters rows
and start
, e.g., at http://wiki.apache.org/solr/CommonQueryParameters. Since OpenCms version 8.5.x you can increase the resulting documents to a size of your choice.
Does OpenCms support result highlighting?
Does the Java API of OpenCms support highlighting?
Currently the OpenCms search API does not support full-featured Solr highlighting. But you can make use of the Solr default highlighting mechanism or course and:
- Call
org.opencms.search.solr.CmsSolrResultList#getSolrQueryResponse()
that returns aSolrQueryResponse
as documented in the solr API documentation. - Or you can use the above mentioned OpenCms Solr Select handler at
http://localhost:8080/opencms/opencms/handleSolrSelect
Please explain the differences between the "Solr Online and Offline"?
As the name of the indexes let assume Offline indexes are also containing changes that have not yet been published and Online indexes only contain thoses resources that have already been published. The "Online EN VFS" is a Lucene based index and also contains only those resources that have been published.
How to rebuild indexes with a fail-safe?
Edit the opencms-search.xml
within your WEB-INF/config
directory and add the following node to your index:
This will create a snapshot as explained here.