title: Solr and product SKUs
body: <p>I'm writing a custom text field type for my product SKUs.</p>
  
  <p>If I have a SKU such as <code>ABC-DEF123G/5</code> (just an example), I want users to be able to search with or without the punctuation. In many cases, only part of the SKU is relevant, e.g. <code>ABC-DEF123</code> in my example.</p>
  
  <p>So far, I've got my <code>schema.xml</code> looking like:</p>
  
  <pre><code>&lt;fieldType name="sku" class="solr.TextField" omitNorms="false"&gt;
      &lt;analyzer&gt;
          &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt;
          &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
          &lt;filter class="solr.WordDelimiterFilterFactory"
              splitOnCaseChange="0"
              splitOnNumerics="0"
              stemEnglishPossessive="0"
              catenateAll="1"
          /&gt;
          &lt;filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="15"/&gt;
      &lt;/analyzer&gt;
  &lt;/fieldType&gt;
  
  &lt;!-- For use in Sunspot: --&gt;
  &lt;dynamicField name="*_sku" stored="false" type="sku" multiValued="true" indexed="true"/&gt;
  </code></pre>
  
  <p>This works well in that I can search for parts of a SKU, e.g. <code>DEF123</code> and get an appropriate result (thanks to the ngram filter). However, searching without punctuation delimiters doesn't return any matches: <code>ABC-DEF123G/5</code> is fine but <code>ABCDEF123G5</code> is not.</p>
  
  <p>When I do analysis on my schema I see that searching for <code>ABCDEF123G5</code> has highlighted matches but when running an actual query there are no results returned.</p>
  
  <p>I have restarted Solr and reindexed my documents. Many times.</p>
  
  <p>Any pearls of wisdom on indexing SKUs or similar?</p>
  
  <hr>
  
  <p>This editor (<a href="https://stackoverflow.com/users/604511/aitchnyu">aitchnyu</a>) added this from Wikipedia:</p>
  
  <blockquote>
    <p>A stock-keeping unit or SKU  is a number or code used to identify each
    unique product or item for sale in a store or other business.</p>
    
    <p>It is a unique identifier for each distinct product and service that
    can be purchased. The usage of SKU is rooted in data management,
    enabling the company to systematically track its inventory or product
    availability, such as in warehouses and retail outlets. They are often
    assigned and serialized at the merchant level. Each SKU is attached to
    an item, variant, product line, bundle, service, fee, or attachment.
    SKUs are often used to refer to different versions of the same
    product. For example, a retail store carrying the game Guitar Hero 3
    might have six SKUs, two for each of the three platforms—one with and
    one without a guitar controller.</p>
  </blockquote>