简体   繁体   中英

Solr fieldtype declaration for special characters in schema file

I would like to store Building & Grounds Maintenance and Art Teacher /Tutor as categoryname and declared a field type as textTight in schema.xml

<fieldType name="textTight" class="solr.TextField" positionIncrementGap="100" >
        <analyzer>
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
            <filter class="solr.WordDelimiterFilterFactory" ignoreCase="true"  splitOnCaseChange="1" generateWordParts="1" generateNumberParts="0" catenateWords="0" catenateNumbers="0" catenateAll="0"/> 
            <filter class="solr.LowerCaseFilterFactory"/>
            <!--<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/> -->
             <filter class="solr.ShingleFilterFactory" maxShingleSize="2" outputUnigrams="true" outputUnigramIfNoNgram="true" />
            <!-- this filter can remove any duplicate tokens that appear at the same position - sometimes
                 possible with WordDelimiterFilter in conjuncton with stemming. -->
            <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>
    </fieldType>

but when querying for categoryname:building & grounds maintenance it getting zero result. What are the changes need in field type declaration. Please help to solve.

Thanks

You might try to store categories as keywords (without any sort of tokenizer).

the most simple way to achieve this is:

<fieldType name="keywords" class="solr.TextField" />

you may incorporate synonyms as well.

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