locked
suggester and analyzer conflict RRS feed

  • Question

  • Hi,

    We try to set Analyzers for columns.

    private void CreateIndex()
            {
                // Create the Azure Search index based on the included schema
                try
                {
                    var definition = new Index()
                    {
                        Name = _indexName,
                        Fields = new[]
                        {
                            new Field("id",     DataType.String)          { IsKey = true,  IsSearchable = false, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true},
                            new Field("name_AAU",   DataType.String)         { IsKey = false, IsSearchable = true,  IsFilterable = true,  IsSortable = true,  IsFacetable = false, IsRetrievable = true, Analyzer="proIndex"},
                            
                        },
                        Suggesters = new[]
                        {
                            new Suggester("suggester01", SuggesterSearchMode.AnalyzingInfixMatching, new List<string>(){"name_AAU",})
                        },
                        Analyzers = new[]
                        {
                            //new CustomAnalyzer("proIndex",TokenizerName.Standard, new List<TokenFilterName>(){ "generateNumberParts", "prefixes" },new List<CharFilterName>(){ "removeDash" } ),
                            new CustomAnalyzer("proIndex",TokenizerName.Standard, new List<TokenFilterName>(){"prefixes"},new List<CharFilterName>(){ "removeDash" } )
                        },
                        TokenFilters = new[]
                        {
                            
                            //new WordDelimiterTokenFilter("generateNumberParts",false,true,null,null,null,false,true,true,false,null),
                            new EdgeNGramTokenFilterV2("prefixes",3,20,null)
                        },
                        CharFilters = new[]
                        {
                            new MappingCharFilter("removeDash",new List<string>() { "-=>"})
                        }
    
    
    
                    };
    
                    _searchServiceClient.Indexes.Create(definition);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error creating index: {0}\r\n", ex.Message.ToString());
                }
    
            }

    and there's a exception said

    {"The request is invalid. Details: definition : Field 'name_AAU' in suggester 'suggester01' uses an unsupported analyzers configuration. Suggesters are only supported with the default analyzer and language analyzers in this version of the API.\r\n"}

    How can we fix it?

    Thank you.

    another question is,

    Can we set two tokenfilters as below??

       TokenFilters = new[]
                        {
                            
                            new WordDelimiterTokenFilter("generateNumberParts",false,true,null,null,null,false,true,true,false,null),
                            new EdgeNGramTokenFilterV2("prefixes",3,20,null)
                        },

    Best Regards,

    Sam


    • Edited by Sam 82 Monday, February 20, 2017 7:17 AM
    Monday, February 20, 2017 7:16 AM

Answers

  • Try:

    TokenFilters = new TokenFilter[]

    { new WordDelimiterTokenFilter("generateNumberParts",false,true,null,null,null,false,true,true,false,null), new EdgeNGramTokenFilterV2("prefixes",3,20,null) }



    • Edited by Janusz Lembicz Tuesday, February 28, 2017 1:42 AM
    • Marked as answer by Sam 82 Wednesday, March 1, 2017 2:22 AM
    Tuesday, February 28, 2017 1:40 AM

All replies

  • Hi Sam, suggesters are not supported on fields that use custom analyzers. In some scenarios it makes sense to create another field analyzed with the standard analyzer (or a language analyzer) and use it for suggestions only. We realize this is a limitation, please vote for this feature to help us prioritize: https://feedback.azure.com/forums/263029-azure-search/suggestions/16079833-allow-suggestions-for-custom-analyzers

    Can you elaborate on your second question? You code that defines two token filters looks good. What's the problem you're experiencing?

    Tuesday, February 21, 2017 6:30 PM
  • Hi Janusz,

    Thanks for the advice.. We'll try to make another field for suggestion.

    The second question is,

    We've use .net SDK v3.0.2 to implement the index functions.

    And there's an error message "No best type found for implicitly-typed array" on these codes


     TokenFilters = new[]
    {                        
           new WordDelimiterTokenFilter("generateNumberParts",false,true,null,null,null,false,true,true,false,null),
           new EdgeNGramTokenFilterV2("prefixes",3,20,null)
    },

    Do you have any clue?~

    Friday, February 24, 2017 1:57 AM
  • Try:

    TokenFilters = new TokenFilter[]

    { new WordDelimiterTokenFilter("generateNumberParts",false,true,null,null,null,false,true,true,false,null), new EdgeNGramTokenFilterV2("prefixes",3,20,null) }



    • Edited by Janusz Lembicz Tuesday, February 28, 2017 1:42 AM
    • Marked as answer by Sam 82 Wednesday, March 1, 2017 2:22 AM
    Tuesday, February 28, 2017 1:40 AM
  • Thank you. It works!

    Wednesday, March 1, 2017 2:24 AM