Umbraco Examine Search (Lucene.net) french accent

在项目中使用Umbraco examine search 来search 法语网站时,客户有一个需求,就是 

当search  expérience 和 experience 时,需要返回一样的结果。 类似这样的需求, 也就是说需要做accents search

 

解决方案:

我们需要重写Analyzer (Lucene.Net.Analysis.Analyzer) 中的 TokenStream方法

using System.IO;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Standard;

namespace MyNamespace
{
    public class CustomAnalyserService : Analyzer
    {
        public override TokenStream TokenStream(string fieldName, TextReader reader)
        {
            StandardTokenizer tokenizer = new StandardTokenizer(Lucene.Net.Util.Version.LUCENE_29, reader);

            tokenizer.SetMaxTokenLength(255);
            TokenStream stream = new StandardFilter(tokenizer);
            stream = new LowerCaseFilter(stream);
            return new ASCIIFoldingFilter(stream);
        }

    }
}

同时修改Umbraco中Examine的配置文件

修改 ExamineSettings.config

Before

<Examine RebuildOnAppStart="true">
  <ExamineIndexProviders>
    <providers>
    
      <!-- default external indexer, which excludes protected and unpublished pages-->
      <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
           analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" />

    </providers>
  </ExamineIndexProviders>

  <ExamineSearchProviders defaultProvider="ExternalSearcher">
    <providers>

      <add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
           analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" />
</providers>
  </ExamineSearchProviders>
</Examine>

 

After

<Examine RebuildOnAppStart="true">
  <ExamineIndexProviders>
    <providers>
    
      <!-- default external indexer, which excludes protected and unpublished pages-->
      <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
           analyzer="MyNamespace.CustomAnalyserService, MyNamespace" />

    </providers>
  </ExamineIndexProviders>

  <ExamineSearchProviders defaultProvider="ExternalSearcher">
    <providers>

      <add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
             analyzer="MyNamespace.CustomAnalyserService, MyNamespace" />
</providers>
  </ExamineSearchProviders>
</Examine>

The only change is the analyzer keyword, where you change it to your assmebly 

analyzer="[Namespace].[Class], [AssemblyWithoutDotDll]"

 

这样之后,ExternalSearcher 就既可以正常的搜索英语,也可以进行accent搜索法语网站 (eg:   expérience 和 experience返回同样的结果)

 

如果有时候发现这样进行法语accent搜索还不行,怎么办

那就在search term这里下功夫,比如输入 expérience进行搜索,我们在这里就把它转换为experience,使用如下方法

public static class SearchHelper
    {


        public static string FoldToASCII(char[] input, int length)
        {
            char[] output;
            int outputPos;
            int targetSize = 4 * length;
            output = new char[ArrayUtil.GetNextSize(targetSize)];
            outputPos = 0;
            for (int index = 0; index < length; ++index)
            {
                char ch = input[index];
                if ((int)ch < 128)
                {
                    output[outputPos++] = ch;
                }
                else
                {
                    switch (ch)
                    {
                        case '':
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'f';
                            continue;
                        case '':
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'i';
                            continue;
                        case '':
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'l';
                            continue;
                        case '':
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'i';
                            continue;
                        case '':
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'f';
                            output[outputPos++] = 'l';
                            continue;
                        case '':
                            output[outputPos++] = 's';
                            output[outputPos++] = 't';
                            continue;
                        case '':
                            output[outputPos++] = '!';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '«':
                        case '»':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '"';
                            continue;
                        case '':
                            output[outputPos++] = '#';
                            continue;
                        case '':
                            output[outputPos++] = '$';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '%';
                            continue;
                        case '':
                            output[outputPos++] = '&';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '\'';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '(';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = ')';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '*';
                            continue;
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '+';
                            continue;
                        case '':
                            output[outputPos++] = ',';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '-';
                            continue;
                        case '':
                            output[outputPos++] = '.';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '/';
                            continue;
                        case '':
                        case '\x2070':
                        case '\x2080':
                        case '\x24EA':
                        case '\x24FF':
                            output[outputPos++] = '0';
                            continue;
                        case '':
                        case '\x2776':
                        case '\x2780':
                        case '\x278A':
                        case '\x2081':
                        case '\x2460':
                        case '\x24F5':
                        case '\x00B9':
                            output[outputPos++] = '1';
                            continue;
                        case '':
                        case '\x2777':
                        case '\x2781':
                        case '\x278B':
                        case '\x2082':
                        case '\x2461':
                        case '\x24F6':
                        case '\x00B2':
                            output[outputPos++] = '2';
                            continue;
                        case '':
                        case '\x2778':
                        case '\x2782':
                        case '\x278C':
                        case '\x2083':
                        case '\x2462':
                        case '\x24F7':
                        case '\x00B3':
                            output[outputPos++] = '3';
                            continue;
                        case '':
                        case '\x2779':
                        case '\x2783':
                        case '\x278D':
                        case '\x2074':
                        case '\x2084':
                        case '\x2463':
                        case '\x24F8':
                            output[outputPos++] = '4';
                            continue;
                        case '':
                        case '\x277A':
                        case '\x2784':
                        case '\x278E':
                        case '\x2075':
                        case '\x2085':
                        case '\x2464':
                        case '\x24F9':
                            output[outputPos++] = '5';
                            continue;
                        case '':
                        case '\x277B':
                        case '\x2785':
                        case '\x278F':
                        case '\x2076':
                        case '\x2086':
                        case '\x2465':
                        case '\x24FA':
                            output[outputPos++] = '6';
                            continue;
                        case '':
                        case '\x277C':
                        case '\x2786':
                        case '\x2790':
                        case '\x2077':
                        case '\x2087':
                        case '\x2466':
                        case '\x24FB':
                            output[outputPos++] = '7';
                            continue;
                        case '':
                        case '\x277D':
                        case '\x2787':
                        case '\x2791':
                        case '\x2078':
                        case '\x2088':
                        case '\x2467':
                        case '\x24FC':
                            output[outputPos++] = '8';
                            continue;
                        case '':
                        case '\x277E':
                        case '\x2788':
                        case '\x2792':
                        case '\x2079':
                        case '\x2089':
                        case '\x2468':
                        case '\x24FD':
                            output[outputPos++] = '9';
                            continue;
                        case '':
                            output[outputPos++] = ':';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = ';';
                            continue;
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '<';
                            continue;
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '=';
                            continue;
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '>';
                            continue;
                        case '':
                            output[outputPos++] = '?';
                            continue;
                        case '':
                            output[outputPos++] = '@';
                            continue;
                        case '':
                        case '':
                        case 'À':
                        case 'Á':
                        case 'Â':
                        case 'Ã':
                        case 'Ä':
                        case 'Å':
                        case 'Ā':
                        case 'Ă':
                        case 'Ą':
                        case 'Ə':
                        case 'Ǎ':
                        case 'Ǟ':
                        case 'Ǡ':
                        case 'Ǻ':
                        case 'Ȁ':
                        case 'Ȃ':
                        case 'Ȧ':
                        case 'Ⱥ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'A';
                            continue;
                        case '':
                        case '':
                        case 'Ɓ':
                        case 'Ƃ':
                        case 'Ƀ':
                        case 'ʙ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'B';
                            continue;
                        case '':
                        case '':
                        case 'Ç':
                        case 'Ć':
                        case 'Ĉ':
                        case 'Ċ':
                        case 'Č':
                        case 'Ƈ':
                        case 'Ȼ':
                        case 'ʗ':
                        case '':
                        case '':
                            output[outputPos++] = 'C';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'Ð':
                        case 'Ď':
                        case 'Đ':
                        case 'Ɖ':
                        case 'Ɗ':
                        case 'Ƌ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'D';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'È':
                        case 'É':
                        case 'Ê':
                        case 'Ë':
                        case 'Ē':
                        case 'Ĕ':
                        case 'Ė':
                        case 'Ę':
                        case 'Ě':
                        case 'Ǝ':
                        case 'Ɛ':
                        case 'Ȅ':
                        case 'Ȇ':
                        case 'Ȩ':
                        case 'Ɇ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'E';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ƒ':
                        case '':
                            output[outputPos++] = 'F';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ĝ':
                        case 'Ğ':
                        case 'Ġ':
                        case 'Ģ':
                        case 'Ɠ':
                        case 'Ǥ':
                        case 'ǥ':
                        case 'Ǧ':
                        case 'ǧ':
                        case 'Ǵ':
                        case 'ɢ':
                        case 'ʛ':
                        case '':
                            output[outputPos++] = 'G';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ĥ':
                        case 'Ħ':
                        case 'Ȟ':
                        case 'ʜ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'H';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'Ì':
                        case 'Í':
                        case 'Î':
                        case 'Ï':
                        case 'Ĩ':
                        case 'Ī':
                        case 'Ĭ':
                        case 'Į':
                        case 'İ':
                        case 'Ɩ':
                        case 'Ɨ':
                        case 'Ǐ':
                        case 'Ȉ':
                        case 'Ȋ':
                        case 'ɪ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'I';
                            continue;
                        case '':
                        case '':
                        case 'Ĵ':
                        case 'Ɉ':
                        case '':
                            output[outputPos++] = 'J';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ķ':
                        case 'Ƙ':
                        case 'Ǩ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'K';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ĺ':
                        case 'Ļ':
                        case 'Ľ':
                        case 'Ŀ':
                        case 'Ł':
                        case 'Ƚ':
                        case 'ʟ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'L';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ɯ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'M';
                            continue;
                        case '':
                        case '':
                        case 'Ñ':
                        case 'Ń':
                        case 'Ņ':
                        case 'Ň':
                        case 'Ŋ':
                        case 'Ɲ':
                        case 'Ǹ':
                        case 'Ƞ':
                        case 'ɴ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'N';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ò':
                        case 'Ó':
                        case 'Ô':
                        case 'Õ':
                        case 'Ö':
                        case 'Ø':
                        case 'Ō':
                        case 'Ŏ':
                        case 'Ő':
                        case 'Ɔ':
                        case 'Ɵ':
                        case 'Ơ':
                        case 'Ǒ':
                        case 'Ǫ':
                        case 'Ǭ':
                        case 'Ǿ':
                        case 'Ȍ':
                        case 'Ȏ':
                        case 'Ȫ':
                        case 'Ȭ':
                        case 'Ȯ':
                        case 'Ȱ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'O';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ƥ':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'P';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ɋ':
                            output[outputPos++] = 'Q';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ŕ':
                        case 'Ŗ':
                        case 'Ř':
                        case 'Ȑ':
                        case 'Ȓ':
                        case 'Ɍ':
                        case 'ʀ':
                        case 'ʁ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'R';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ś':
                        case 'Ŝ':
                        case 'Ş':
                        case 'Š':
                        case 'Ș':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'S';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'Ţ':
                        case 'Ť':
                        case 'Ŧ':
                        case 'Ƭ':
                        case 'Ʈ':
                        case 'Ț':
                        case 'Ⱦ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'T';
                            continue;
                        case '':
                        case '':
                        case 'Ù':
                        case 'Ú':
                        case 'Û':
                        case 'Ü':
                        case 'Ũ':
                        case 'Ū':
                        case 'Ŭ':
                        case 'Ů':
                        case 'Ű':
                        case 'Ų':
                        case 'Ư':
                        case 'Ǔ':
                        case 'Ǖ':
                        case 'Ǘ':
                        case 'Ǚ':
                        case 'Ǜ':
                        case 'Ȕ':
                        case 'Ȗ':
                        case 'Ʉ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'U';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ʋ':
                        case 'Ʌ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'V';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'Ŵ':
                        case 'Ƿ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'W';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'X';
                            continue;
                        case '':
                        case '':
                        case 'Ý':
                        case 'Ŷ':
                        case 'Ÿ':
                        case 'Ƴ':
                        case 'Ȳ':
                        case 'Ɏ':
                        case 'ʏ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'Y';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'Ź':
                        case 'Ż':
                        case 'Ž':
                        case 'Ƶ':
                        case 'Ȝ':
                        case 'Ȥ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'Z';
                            continue;
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = '[';
                            continue;
                        case '':
                            output[outputPos++] = '\\';
                            continue;
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = ']';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '^';
                            continue;
                        case '_':
                            output[outputPos++] = '_';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'à':
                        case 'á':
                        case 'â':
                        case 'ã':
                        case 'ä':
                        case 'å':
                        case 'ā':
                        case 'ă':
                        case 'ą':
                        case 'ǎ':
                        case 'ǟ':
                        case 'ǡ':
                        case 'ǻ':
                        case 'ȁ':
                        case 'ȃ':
                        case 'ȧ':
                        case 'ɐ':
                        case 'ə':
                        case 'ɚ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'a';
                            continue;
                        case '':
                        case '':
                        case 'ƀ':
                        case 'ƃ':
                        case 'ɓ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'b';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ç':
                        case 'ć':
                        case 'ĉ':
                        case 'ċ':
                        case 'č':
                        case 'ƈ':
                        case 'ȼ':
                        case 'ɕ':
                        case '':
                            output[outputPos++] = 'c';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ð':
                        case 'ď':
                        case 'đ':
                        case 'ƌ':
                        case 'ȡ':
                        case 'ɖ':
                        case 'ɗ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'd';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'è':
                        case 'é':
                        case 'ê':
                        case 'ë':
                        case 'ē':
                        case 'ĕ':
                        case 'ė':
                        case 'ę':
                        case 'ě':
                        case 'ǝ':
                        case 'ȅ':
                        case 'ȇ':
                        case 'ȩ':
                        case 'ɇ':
                        case 'ɘ':
                        case 'ɛ':
                        case 'ɜ':
                        case 'ɝ':
                        case 'ɞ':
                        case 'ʚ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ế':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'e';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ƒ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'f';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ĝ':
                        case 'ğ':
                        case 'ġ':
                        case 'ģ':
                        case 'ǵ':
                        case 'ɠ':
                        case 'ɡ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'g';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ĥ':
                        case 'ħ':
                        case 'ȟ':
                        case 'ɥ':
                        case 'ɦ':
                        case 'ʮ':
                        case 'ʯ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'h';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ì':
                        case 'í':
                        case 'î':
                        case 'ï':
                        case 'ĩ':
                        case 'ī':
                        case 'ĭ':
                        case 'į':
                        case 'ı':
                        case 'ǐ':
                        case 'ȉ':
                        case 'ȋ':
                        case 'ɨ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'i';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ĵ':
                        case 'ǰ':
                        case 'ȷ':
                        case 'ɉ':
                        case 'ɟ':
                        case 'ʄ':
                        case 'ʝ':
                            output[outputPos++] = 'j';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ķ':
                        case 'ƙ':
                        case 'ǩ':
                        case 'ʞ':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'k';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ĺ':
                        case 'ļ':
                        case 'ľ':
                        case 'ŀ':
                        case 'ł':
                        case 'ƚ':
                        case 'ȴ':
                        case 'ɫ':
                        case 'ɬ':
                        case 'ɭ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'l';
                            continue;
                        case '':
                        case '':
                        case 'ɯ':
                        case 'ɰ':
                        case 'ɱ':
                        case '':
                        case '':
                        case 'ḿ':
                        case '':
                        case '':
                            output[outputPos++] = 'm';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ñ':
                        case 'ń':
                        case 'ņ':
                        case 'ň':
                        case 'ʼn':
                        case 'ŋ':
                        case 'ƞ':
                        case 'ǹ':
                        case 'ȵ':
                        case 'ɲ':
                        case 'ɳ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'n';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ò':
                        case 'ó':
                        case 'ô':
                        case 'õ':
                        case 'ö':
                        case 'ø':
                        case 'ō':
                        case 'ŏ':
                        case 'ő':
                        case 'ơ':
                        case 'ǒ':
                        case 'ǫ':
                        case 'ǭ':
                        case 'ǿ':
                        case 'ȍ':
                        case 'ȏ':
                        case 'ȫ':
                        case 'ȭ':
                        case 'ȯ':
                        case 'ȱ':
                        case 'ɔ':
                        case 'ɵ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'o';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ƥ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'p';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ĸ':
                        case 'ɋ':
                        case 'ʠ':
                            output[outputPos++] = 'q';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ŕ':
                        case 'ŗ':
                        case 'ř':
                        case 'ȑ':
                        case 'ȓ':
                        case 'ɍ':
                        case 'ɼ':
                        case 'ɽ':
                        case 'ɾ':
                        case 'ɿ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'r';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ś':
                        case 'ŝ':
                        case 'ş':
                        case 'š':
                        case 'ſ':
                        case 'ș':
                        case 'ȿ':
                        case 'ʂ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 's';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ţ':
                        case 'ť':
                        case 'ŧ':
                        case 'ƫ':
                        case 'ƭ':
                        case 'ț':
                        case 'ȶ':
                        case 'ʇ':
                        case 'ʈ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 't';
                            continue;
                        case '':
                        case '':
                        case 'ù':
                        case 'ú':
                        case 'û':
                        case 'ü':
                        case 'ũ':
                        case 'ū':
                        case 'ŭ':
                        case 'ů':
                        case 'ű':
                        case 'ų':
                        case 'ư':
                        case 'ǔ':
                        case 'ǖ':
                        case 'ǘ':
                        case 'ǚ':
                        case 'ǜ':
                        case 'ȕ':
                        case 'ȗ':
                        case 'ʉ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'u';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ʋ':
                        case 'ʌ':
                        case '':
                        case '':
                        case '':
                        case 'ṿ':
                            output[outputPos++] = 'v';
                            continue;
                        case '':
                        case '':
                        case '':
                        case 'ŵ':
                        case 'ƿ':
                        case 'ʍ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'w';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'x';
                            continue;
                        case '':
                        case '':
                        case 'ý':
                        case 'ÿ':
                        case 'ŷ':
                        case 'ƴ':
                        case 'ȳ':
                        case 'ɏ':
                        case 'ʎ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ỿ':
                            output[outputPos++] = 'y';
                            continue;
                        case '':
                        case '':
                        case '':
                        case '':
                        case 'ź':
                        case 'ż':
                        case 'ž':
                        case 'ƶ':
                        case 'ȝ':
                        case 'ȥ':
                        case 'ɀ':
                        case 'ʐ':
                        case 'ʑ':
                        case '':
                        case '':
                        case '':
                        case '':
                        case '':
                            output[outputPos++] = 'z';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '{';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '}';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = '~';
                            continue;
                        case '':
                            output[outputPos++] = 'T';
                            output[outputPos++] = 'Z';
                            continue;
                        case '':
                            output[outputPos++] = 't';
                            output[outputPos++] = 'z';
                            continue;
                        case '':
                            output[outputPos++] = 'A';
                            output[outputPos++] = 'A';
                            continue;
                        case '':
                            output[outputPos++] = 'a';
                            output[outputPos++] = 'a';
                            continue;
                        case '':
                            output[outputPos++] = 'A';
                            output[outputPos++] = 'O';
                            continue;
                        case '':
                            output[outputPos++] = 'a';
                            output[outputPos++] = 'o';
                            continue;
                        case '':
                            output[outputPos++] = 'A';
                            output[outputPos++] = 'U';
                            continue;
                        case '':
                            output[outputPos++] = 'a';
                            output[outputPos++] = 'u';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = 'A';
                            output[outputPos++] = 'V';
                            continue;
                        case '':
                        case '':
                            output[outputPos++] = 'a';
                            output[outputPos++] = 'v';
                            continue;
                        case '':
                            output[outputPos++] = 'A';
                            output[outputPos++] = 'Y';
                            continue;
                        case '':
                            output[outputPos++] = 'a';
                            output[outputPos++] = 'y';
                            continue;
                        case '':
                            output[outputPos++] = 'O';
                            output[outputPos++] = 'O';
                            continue;
                        case '':
                            output[outputPos++] = 'o';
                            output[outputPos++] = 'o';
                            continue;
                        case '':
                            output[outputPos++] = 'V';
                            output[outputPos++] = 'Y';
                            continue;
                        case '':
                            output[outputPos++] = 'v';
                            output[outputPos++] = 'y';
                            continue;
                        case '':
                        case 'Þ':
                            output[outputPos++] = 'T';
                            output[outputPos++] = 'H';
                            continue;
                        case '':
                        case 'þ':
                        case '':
                            output[outputPos++] = 't';
                            output[outputPos++] = 'h';
                            continue;
                        case '\x277F':
                        case '\x2789':
                        case '\x2793':
                        case '\x2469':
                        case '\x24FE':
                            output[outputPos++] = '1';
                            output[outputPos++] = '0';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = '(';
                            continue;
                        case '':
                            output[outputPos++] = ')';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '!';
                            output[outputPos++] = '!';
                            continue;
                        case '':
                            output[outputPos++] = '?';
                            output[outputPos++] = '?';
                            continue;
                        case '':
                            output[outputPos++] = '?';
                            output[outputPos++] = '!';
                            continue;
                        case '':
                            output[outputPos++] = '!';
                            output[outputPos++] = '?';
                            continue;
                        case '\x246A':
                        case '\x24EB':
                            output[outputPos++] = '1';
                            output[outputPos++] = '1';
                            continue;
                        case '\x246B':
                        case '\x24EC':
                            output[outputPos++] = '1';
                            output[outputPos++] = '2';
                            continue;
                        case '\x246C':
                        case '\x24ED':
                            output[outputPos++] = '1';
                            output[outputPos++] = '3';
                            continue;
                        case '\x246D':
                        case '\x24EE':
                            output[outputPos++] = '1';
                            output[outputPos++] = '4';
                            continue;
                        case '\x246E':
                        case '\x24EF':
                            output[outputPos++] = '1';
                            output[outputPos++] = '5';
                            continue;
                        case '\x246F':
                        case '\x24F0':
                            output[outputPos++] = '1';
                            output[outputPos++] = '6';
                            continue;
                        case '\x2470':
                        case '\x24F1':
                            output[outputPos++] = '1';
                            output[outputPos++] = '7';
                            continue;
                        case '\x2471':
                        case '\x24F2':
                            output[outputPos++] = '1';
                            output[outputPos++] = '8';
                            continue;
                        case '\x2472':
                        case '\x24F3':
                            output[outputPos++] = '1';
                            output[outputPos++] = '9';
                            continue;
                        case '\x2473':
                        case '\x24F4':
                            output[outputPos++] = '2';
                            output[outputPos++] = '0';
                            continue;
                        case '\x2474':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2475':
                            output[outputPos++] = '(';
                            output[outputPos++] = '2';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2476':
                            output[outputPos++] = '(';
                            output[outputPos++] = '3';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2477':
                            output[outputPos++] = '(';
                            output[outputPos++] = '4';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2478':
                            output[outputPos++] = '(';
                            output[outputPos++] = '5';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2479':
                            output[outputPos++] = '(';
                            output[outputPos++] = '6';
                            output[outputPos++] = ')';
                            continue;
                        case '\x247A':
                            output[outputPos++] = '(';
                            output[outputPos++] = '7';
                            output[outputPos++] = ')';
                            continue;
                        case '\x247B':
                            output[outputPos++] = '(';
                            output[outputPos++] = '8';
                            output[outputPos++] = ')';
                            continue;
                        case '\x247C':
                            output[outputPos++] = '(';
                            output[outputPos++] = '9';
                            output[outputPos++] = ')';
                            continue;
                        case '\x247D':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '0';
                            output[outputPos++] = ')';
                            continue;
                        case '\x247E':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '1';
                            output[outputPos++] = ')';
                            continue;
                        case '\x247F':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '2';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2480':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '3';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2481':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '4';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2482':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '5';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2483':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '6';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2484':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '7';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2485':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '8';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2486':
                            output[outputPos++] = '(';
                            output[outputPos++] = '1';
                            output[outputPos++] = '9';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2487':
                            output[outputPos++] = '(';
                            output[outputPos++] = '2';
                            output[outputPos++] = '0';
                            output[outputPos++] = ')';
                            continue;
                        case '\x2488':
                            output[outputPos++] = '1';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2489':
                            output[outputPos++] = '2';
                            output[outputPos++] = '.';
                            continue;
                        case '\x248A':
                            output[outputPos++] = '3';
                            output[outputPos++] = '.';
                            continue;
                        case '\x248B':
                            output[outputPos++] = '4';
                            output[outputPos++] = '.';
                            continue;
                        case '\x248C':
                            output[outputPos++] = '5';
                            output[outputPos++] = '.';
                            continue;
                        case '\x248D':
                            output[outputPos++] = '6';
                            output[outputPos++] = '.';
                            continue;
                        case '\x248E':
                            output[outputPos++] = '7';
                            output[outputPos++] = '.';
                            continue;
                        case '\x248F':
                            output[outputPos++] = '8';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2490':
                            output[outputPos++] = '9';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2491':
                            output[outputPos++] = '1';
                            output[outputPos++] = '0';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2492':
                            output[outputPos++] = '1';
                            output[outputPos++] = '1';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2493':
                            output[outputPos++] = '1';
                            output[outputPos++] = '2';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2494':
                            output[outputPos++] = '1';
                            output[outputPos++] = '3';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2495':
                            output[outputPos++] = '1';
                            output[outputPos++] = '4';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2496':
                            output[outputPos++] = '1';
                            output[outputPos++] = '5';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2497':
                            output[outputPos++] = '1';
                            output[outputPos++] = '6';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2498':
                            output[outputPos++] = '1';
                            output[outputPos++] = '7';
                            output[outputPos++] = '.';
                            continue;
                        case '\x2499':
                            output[outputPos++] = '1';
                            output[outputPos++] = '8';
                            output[outputPos++] = '.';
                            continue;
                        case '\x249A':
                            output[outputPos++] = '1';
                            output[outputPos++] = '9';
                            output[outputPos++] = '.';
                            continue;
                        case '\x249B':
                            output[outputPos++] = '2';
                            output[outputPos++] = '0';
                            output[outputPos++] = '.';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'a';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'b';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'c';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'd';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'e';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'f';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'g';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'h';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'i';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'j';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'k';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'l';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'm';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'n';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'o';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'p';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'q';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'r';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 's';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 't';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'u';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'v';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'w';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'x';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'y';
                            output[outputPos++] = ')';
                            continue;
                        case '':
                            output[outputPos++] = '(';
                            output[outputPos++] = 'z';
                            output[outputPos++] = ')';
                            continue;
                        case 'Æ':
                        case 'Ǣ':
                        case 'Ǽ':
                        case '':
                            output[outputPos++] = 'A';
                            output[outputPos++] = 'E';
                            continue;
                        case 'ß':
                            output[outputPos++] = 's';
                            output[outputPos++] = 's';
                            continue;
                        case 'æ':
                        case 'ǣ':
                        case 'ǽ':
                        case '':
                            output[outputPos++] = 'a';
                            output[outputPos++] = 'e';
                            continue;
                        case 'IJ':
                            output[outputPos++] = 'I';
                            output[outputPos++] = 'J';
                            continue;
                        case 'ij':
                            output[outputPos++] = 'i';
                            output[outputPos++] = 'j';
                            continue;
                        case 'Œ':
                        case 'ɶ':
                            output[outputPos++] = 'O';
                            output[outputPos++] = 'E';
                            continue;
                        case 'œ':
                        case '':
                            output[outputPos++] = 'o';
                            output[outputPos++] = 'e';
                            continue;
                        case 'ƕ':
                            output[outputPos++] = 'h';
                            output[outputPos++] = 'v';
                            continue;
                        case 'DŽ':
                        case 'DZ':
                            output[outputPos++] = 'D';
                            output[outputPos++] = 'Z';
                            continue;
                        case 'Dž':
                        case 'Dz':
                            output[outputPos++] = 'D';
                            output[outputPos++] = 'z';
                            continue;
                        case 'dž':
                        case 'dz':
                        case 'ʣ':
                        case 'ʥ':
                            output[outputPos++] = 'd';
                            output[outputPos++] = 'z';
                            continue;
                        case 'LJ':
                            output[outputPos++] = 'L';
                            output[outputPos++] = 'J';
                            continue;
                        case 'Lj':
                            output[outputPos++] = 'L';
                            output[outputPos++] = 'j';
                            continue;
                        case 'lj':
                            output[outputPos++] = 'l';
                            output[outputPos++] = 'j';
                            continue;
                        case 'NJ':
                            output[outputPos++] = 'N';
                            output[outputPos++] = 'J';
                            continue;
                        case 'Nj':
                            output[outputPos++] = 'N';
                            output[outputPos++] = 'j';
                            continue;
                        case 'nj':
                            output[outputPos++] = 'n';
                            output[outputPos++] = 'j';
                            continue;
                        case 'Ƕ':
                            output[outputPos++] = 'H';
                            output[outputPos++] = 'V';
                            continue;
                        case 'Ȣ':
                        case '':
                            output[outputPos++] = 'O';
                            output[outputPos++] = 'U';
                            continue;
                        case 'ȣ':
                            output[outputPos++] = 'o';
                            output[outputPos++] = 'u';
                            continue;
                        case 'ȸ':
                            output[outputPos++] = 'd';
                            output[outputPos++] = 'b';
                            continue;
                        case 'ȹ':
                            output[outputPos++] = 'q';
                            output[outputPos++] = 'p';
                            continue;
                        case 'ʦ':
                            output[outputPos++] = 't';
                            output[outputPos++] = 's';
                            continue;
                        case 'ʨ':
                            output[outputPos++] = 't';
                            output[outputPos++] = 'c';
                            continue;
                        case 'ʪ':
                            output[outputPos++] = 'l';
                            output[outputPos++] = 's';
                            continue;
                        case 'ʫ':
                            output[outputPos++] = 'l';
                            output[outputPos++] = 'z';
                            continue;
                        case '':
                            output[outputPos++] = 'u';
                            output[outputPos++] = 'e';
                            continue;
                        case '':
                            output[outputPos++] = 'S';
                            output[outputPos++] = 'S';
                            continue;
                        case '':
                            output[outputPos++] = 'L';
                            output[outputPos++] = 'L';
                            continue;
                        case '':
                            output[outputPos++] = 'l';
                            output[outputPos++] = 'l';
                            continue;
                        default:
                            output[outputPos++] = ch;
                            continue;
                    }
                }
            }
            return new string(output).Trim('\0');
        }
    }

 

 

另外,我们在把新修改后的ExamineSettings.config 发布到web server后,需要rebuild index 去使它工作。

但是,在我们的web server上,我们并没有Umbraco back office, 我们把back office删除了. 如何rebuild index 呢

方法是把 App_Data\TEMP\ExamineIndexes\machinename\ 中的 External 文件夹删除。然后在IIS 中的App pool重新启动这个网站

然后再测试,应该就可以了

 

posted on 2018-04-12 06:26  新西兰程序员  阅读(853)  评论(0编辑  收藏  举报