[opencms-dev] How do I stock the first letter of a field in Solr ?

Rüdiger Kurz r.kurz at alkacon.com
Tue Dec 11 17:13:45 CET 2012


Hi Siegfried,

there are multiple options doing this:

1. Using Solr techniques I would suggest to write a analyzer/tokenizer 
and define a own field type within the schema.xml that is used by the 
Solr core.
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters

2. Using OpenCms techniques you can extend the class 
org.opencms.search.fields.CmsSearchFieldMapping and configure it within 
the XSD schema of your content.

As entry point have a look at:
org.opencms.search.solr.CmsDynamicDummyField in the test package and do 
something like:

<searchsetting element="MyElement">
   <solrfield targetfield="my.element">
     <mapping type="dynamic" 
class="org.opencms.search.solr.CmsDynamicDummyField">special</mapping>
   </solrfield>
</searchsetting>

Good luck!

Am 11.12.2012 16:22, schrieb Siegfried Ehret:
> Hi,
> I want to make a filter by first letter for my elements.
> I can't use a solrQuery since they don't accept query for one letter.
> Hence, I want to do this using a special field, where I will store the first letter from my element's title.
>
> Thanks in advance
>

-- 
Kind Regards,
Rüdiger.

-------------------

Rüdiger Kurz

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org



More information about the opencms-dev mailing list