The Solr schema.xml has by default the “string” fieldType.

<fieldType name="string" class="solr.StrField" sortMissingLast="true" />

Add the following fieldType to your schema.xml and use it as field type for your field:

<fieldType name="string_rev" class="solr.TextField" sortMissingLast="true">
    <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="(\s+)" replacement="" replace="all" />
        <filter class="solr.ReversedWildcardFilterFactory" />
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="(\s+)" replacement="" replace="all" />
    </analyzer>
</fieldType>

As example we take the index value “john doe”. By default Solr doesn’t support a wildcard at the begin of the term like “*doe”, only “doe*”. But it is possible to achieve this by using the solr.ReversedWildcardFilterFactory filter.

But we still have one problem left. Wildcard search on two words isn’t possible. This can be fixed to remove all whitespaces. Pass the value “John Doe” at indexing time to Solr and it will be stored as “John Doe”, but indexed as “johndoe” because of the solr.PatternReplaceFilterFactory filter. At query time, search without spaces and in lowercase like “*hndo*” and it will match!

Please note that with wildcard queries analyzers are not supplied, so make sure your search term is already in lowercase. Also make sure that you search as term and NOT as phrase with double quotes around it.