Federico Degrandis
Federico Degrandis

Reputation: 197

Use wildcard with different analyzer than the standard one in Azure Search

I need to allow text free search for values containing dashes, so like ABCD-12EF.

I know that the standard analyzer does not work well with - because it splits the content in multiple tokens. I've created an index like the one below to try out keyword and whitespace analyzers but it seems like that the * chars does not work anymore. I get results only if I search for the complete value without * so ABCD-12EF. If I search for ABCD-12EF or ABCD-12* or ABCD* I dont'get any result.

Any idea why?

public class IndexTryOut
{
    [Key, IsFilterable]
    public string Id { get; set; }

    [IsSearchable, IsFilterable]
    [Analyzer("keyword")]
    public string Data1 { get; set; }

    [IsSearchable, IsFilterable]
    [Analyzer("whitespace")]
    public string Data2 { get; set; }
}

Upvotes: 0

Views: 345

Answers (1)

Nati Nimni
Nati Nimni

Reputation: 258

You can define a custom analyzer that uses a “keyword” tokenizer with a “lowercase” token filter - see my answer to this question: How to index a field with alphanumeric characters AND a dash for wildcard search.

Upvotes: 1

Related Questions