In a Regex, how to remove all the leading, trailing and where ever spaces exist in SOLR.
To remove special characters, we can have the PatternReplaceFilterFactory as
<filter class="solr.PatternReplaceFilterFactory" pattern="([^a-z])" replacement="" replace="all" />
What pattern value will be formed to remove the spaces whereever it comes.
I don't know SOLR but based on your example I guess you could just do
<filter class="solr.PatternReplaceFilterFactory" pattern="(\s+)" replacement="" replace="all" />
to remove all spaces
or
<filter class="solr.PatternReplaceFilterFactory" pattern="(^\s+|\s+$)" replacement="" replace="all" />
to remove just leading and trailing spaces.
Use the trim filter to remove leading and trailing spaces. http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.TrimFilterFactory
just replacing everything not a-z with nothing will cause strange things to happen and is not a good idea.
solr.TrimFilterFactory , can be used to remove leading and trailing spaces without regex.