Many users coming from traditional RDBMS systems are used to wildcard searches. The most common of them
are the ones using *
characters which means zero or more characters. You have probably seen searches like the one as follows:
AND name LIKE 'ABC12%'
So how to do that with Solr and not kill our Solr server? This task will show you how to prepare your data and make efficient searches.
The first step is to create a proper index structure. Let's assume we have the following one (add this to your
schema.xml
file to the field definition section):<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="string_wildcard" indexed="true" stored="true" />
Now, let's define our
string_wildcard
type (add this to theschema.xml
file):<fieldType name="string_wildcard" class="solr.TextField"> <analyzer type="index"> <tokenizer class="solr.WhitespaceTokenizerFactory...