Take a look at your admin/analysis page and put your tokens in for both
index and query times. What I think you'll see is that the # is being
stripped at query time due to the first PatternReplaceFilterFactory.

You probably want to split your analyzers into an index-time and query-time
pair and do the appropriate replacements to keep # at quer time.


Best
Erick

On Tue, Oct 25, 2011 at 12:27 PM, Daniel Bradley
<daniel.brad...@adfero.co.uk> wrote:
> When running a search such as:
>  field_name:#
>  field_name:"#"
>  field_name:"\#"
>
> where there is a record with the value of exactly "#", solr returns 0 rows.
>
> The workaround we are having to use is to use a range query on the
> field such as:
>  field_name:[# TO #]
> and this returns the correct documents.
>
> Use case details:
> We have a field that indexes a text field and calculates a "letter
> group". This keeps only the first significant character from a value
> (number or letter), and if it is a number the simply stores "#" as we
> want all numbered items grouped together.
>
> I'm also aware that we could also fix this by using a specific number
> instead of the hash character, however, I though I'd raise this to see
> if there is a wider issue. I've listed some specific details below.
>
> Thanks for your time,
>
> Daniel Bradley
>
>
> Field definition:
>    <fieldType name="letterGrouping" class="solr.TextField"
> sortMissingLast="true" omitNorms="true">
>      <analyzer>
>        <tokenizer class="solr.PatternTokenizerFactory"
> pattern="^([a-zA-Z0-9]).*" group="1"/>
>        <filter class="solr.LowerCaseFilterFactory" />
>        <filter class="solr.TrimFilterFactory" />
>        <filter class="solr.PatternReplaceFilterFactory"
>                pattern="([^a-z0-9])" replacement="" replace="all"
>        />
>        <filter class="solr.PatternReplaceFilterFactory"
>                pattern="([0-9])" replacement="#" replace="all"
>        />
>      </analyzer>
>    </fieldType>
>
> Server information:
> Solr Specification Version: 3.2.0
> Solr Implementation Version: 3.2.0 1129474 - rmuir - 2011-05-30 23:07:15
> Lucene Specification Version: 3.2.0
> Lucene Implementation Version: 3.2.0 1129474 - 2011-05-30 23:08:57
>

Reply via email to