简体   繁体   中英

uppercase in solr analyzer

I want to copy value from one field and make uppercase of the value and put it in another field

In my schema.xml the field "facility and uppercaseFacility" looks like

<field name="facility" type="text" indexed="true" stored="true"/>
<field name="facilityuppercaseFacility" type="text" indexed="true" stored="true"/>

If I'm not wrong I need to write my own Java code and use it in analyzer to accomplish it.

Meanwhile i followed this link http://solr.pl/en/2012/05/14/developing-your-own-solr-filter/

I got this error..

Caused by: org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] analyzer/filter: class pl.solr.solr2.ReverseFilterFactory
    at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
    at org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:400)
    at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:95)
    at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
    at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
    ... 14 more
Caused by: java.lang.ClassCastException: class pl.solr.solr2.ReverseFilterFactory
    at java.lang.Class.asSubclass(Class.java:3126)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:454)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:573)
    at org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:382)
    at org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:376)
    at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
    ... 18 more

I've no idea, what it says and I don't know how to fix it.

Do you wanted visual representation of the other field to be upper class? Or the indexed one (one used for search). Analyzer chain does not affect the original (stored) representation, only what gets indexed. Which you do not see, except for edge cases like faceting (which uses indexed representation).

So, you need to be clear on what you are trying to achieve.

  1. If you want the indexed representation, latest (4.8+) version of Solr does have UpperCaseFilterFactory .
  2. If you want the visual representation to be upper case as well, you have to do with UpdateRequestProcessor (URP) chain instead. Something like Clone URP . There is no UpperCase URP, you'll need to write a custom one. And, if this is your first exposure to URPs, make sure to read the WIKI and include the LogURP and RunURP in the chain, otherwise, no document will ever actually make it into Solr.

If you want to see what else is available, you can find the full lists of URPs and Analyzers at http://solr-start.com .

Yes. You're correct. There isn't any UpperCaseFilterFactory by default. So you need to write it on your own. But I've strongly don't recommend it. Plz read this for clarification - http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201205.mbox/%3CA60A9075-7AEC-4A15-A9EA-9C83CAF8B676@wunderwood.org%3E

In Unicode, uppercasing characters loses information, because there are some upper case characters that represent more than one lower case character.

Lower casing text is safe, so always lower-case.

Anyway, if you decide to do that - you need to implement this abstract class http://lucene.apache.org/core/4_7_0/analyzers-common/org/apache/lucene/analysis/util/TokenFilterFactory.html and then add into your schema.xml something like that

检查您的类路径中是否没有较旧/混合的Solr库,因为它可能试图转换为较早版本的BaseTokenFilterFactory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM