Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess you are looking for <strong>Alphabetic Range Bucketing</strong>. There is no feature in Solr that provides this feature out of the box. But you can use creative hack with additional step of text analysis. This following may help in your case,</p> <p>Create Field Type: letterRangeFieldType</p> <pre class="lang-xml prettyprint-override"><code>&lt;fieldType name="letterRangeFieldType" class="solr.TextField"&gt; &lt;analyzer type="index"&gt; &lt;tokenizer class="solr.PatternTokenizerFactory" pattern="^([a-zA-Z]).*" group="1" /&gt; &lt;filter class="solr.SynonymFilterFactory" synonyms="letterRanges.txt" ignoreCase="true" expand="false"/&gt; &lt;/analyzer&gt; &lt;analyzer type="query"&gt; &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt; &lt;/analyzer&gt; &lt;/fieldType&gt; </code></pre> <p>Create Field with that field type:</p> <pre class="lang-xml prettyprint-override"><code>&lt;field name="firstNameFacetLetter" type="letterRangeFieldType" stored="false" /&gt; </code></pre> <p>Create copy field that copies the first names into the new field that will bucketise:</p> <pre class="lang-xml prettyprint-override"><code>&lt;copyField source="firstName" dest="firstNameFacetLetter" /&gt; </code></pre> <p>To sum it up, while indexing the PatternTokenizerFactory takes first character from first name and maps it to the range base on the range of synonyms defined in <code>synonyms="letterRanges.txt"</code>. For example first name with <code>Foo</code> will map to <code>D - F</code>. </p> <p>Finally, you can run facet on the new field with sort by <code>lex</code> order. You will get results like so,</p> <pre class="lang-xml prettyprint-override"><code>&lt;lst name="firstNameFacetLetter"&gt; &lt;int name="A-C"&gt;99&lt;/int&gt; &lt;int name="D-F"&gt;76&lt;/int&gt; &lt;int name="G-I"&gt;52&lt;/int&gt; ... </code></pre> <p>You need to customize to fit your ranges &amp; requirements, but this may help you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload