Multiple replacement / substitute NGgram string SOLR 8.6

28 Views Asked by At

I've built a number plate search using Drupal and SOLR.

I'm trying to work out how to create searchable tokens that replace letters/numbers with other letters/numbers.

For example. I'd like BOY to be found when the search is 80Y

I've got an analyzer set up as

<analyzer type="index">
  <tokenizer class="solr.EdgeNGramTokenizerFactory" minGramSize="1" maxGramSize="7"  />
  <filter class="solr.SynonymGraphFilterFactory" synonyms="mapping.txt" format="solr" ignoreCase="true" expand="true" />
  <filter class="solr.FlattenGraphFilterFactory"/> <!-- required on index analyzers after graph filters -->
  <filter class="solr.LengthFilterFactory" min="2" max="7"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.ReverseStringFilterFactory" />
  <filter class="solr.BeiderMorseFilterFactory" nameType="GENERIC" ruleType="APPROX" concat="true" languageSet="auto" />
</analyzer>

However with synonym text file as:

8 => B
B => 8
0 => O
O => 0 

the index analysis is:

EdgeNGramTokenizer  b   bo  boy
SynonymGraphFilter  8   bo  boy
FlattenGraphFilter  8   bo  boy

How do I concatenate or have concurrent replacements without having to populate mapping.txt with all of the possibilites?

Another example would be JAM => J4M, JHM where A=4 and 4=H.

Am I on the right track here?

0

There are 0 best solutions below