Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I stumbled upon this thread since I got the same problem. Here's the NEST code to create an index with an AsciiFolding Analyzer:</p> <pre><code>// Create the Client string indexName = "testindex"; var uri = new Uri("http://localhost:9200"); var settings = new ConnectionSettings(uri).SetDefaultIndex(indexName); var client = new ElasticClient(settings); // Create new Index Settings IndexSettings set = new IndexSettings(); // Create a Custom Analyzer ... var an = new CustomAnalyzer(); // ... based on the standard Tokenizer an.Tokenizer = "standard"; // ... with Filters from the StandardAnalyzer an.Filter = new List&lt;string&gt;(); an.Filter.Add("standard"); an.Filter.Add("lowercase"); an.Filter.Add("stop"); // ... just adding the additional AsciiFoldingFilter at the end an.Filter.Add("asciifolding"); // Add the Analyzer with a name set.Analysis.Analyzers.Add("nospecialchars", an); // Create the Index client.CreateIndex(indexName, set); </code></pre> <p>Now you can Map your Entity to this index (it's important to do this after you created the Index)</p> <pre><code>client.MapFromAttributes&lt;TestEntity&gt;(); </code></pre> <p>And here's how such an entity could look like:</p> <pre><code>[ElasticType(Name = "TestEntity", DisableAllField = true)] public class TestEntity { public TestEntity(int id, string desc) { ID = id; Description = desc; } public int ID { get; set; } [ElasticProperty(Analyzer = "nospecialchars")] public string Description { get; set; } } </code></pre> <p>There you go, the Description-Field is now inserted into the index without accents. You can test this if you check the Mapping of your index:</p> <pre><code>http://localhost:9200/testindex/_mapping </code></pre> <p>Which then should look something like:</p> <pre><code>{ testindex: { TestEntity: { _all: { enabled: false }, properties: { description: { type: "string", analyzer: "nospecialchars" }, iD: { type: "integer" } } } } } </code></pre> <p>Hope this will help someone.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload