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

Rüdiger Kurz r.kurz at alkacon.com
Wed Dec 12 10:01:31 CET 2012


Hi Siegfried,

Maybe it's more efficient to add something like:

<field name="firstChar" type="string" indexed="true" stored="true" 
maxChars="1" />

<copyField source="mySource" dest="firstChar" />

to the schema.xml of Solr, whereby 'mySource' is the name of the field 
that holds the element's title you want to store the first letter from. 
A feedback for me and also for the dev-list would be nice!

cheers
Rüdiger

Am 11.12.2012 17:13, schrieb Rüdiger Kurz:
> 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