Elastic Search-Search string having spaces and special characters in it using C#

后端 未结 3 1495
执笔经年
执笔经年 2020-12-19 11:01

I am looking for ElasticSearch nest query which will provide exact match on string having spaces in it using C#.

for example - I want to search for a word like \'XYZ

3条回答
  •  暖寄归人
    2020-12-19 11:13

    Please refer the below code ,I think this will meet your requirements. Here I have created and mapped index with dynamic template and then did the XDCR. Now all string fields will be not_analysed.

     IIndicesOperationResponse result = null;
                        if (!objElasticClient.IndexExists(elastic_indexname).Exists)
                        {
                            result = objElasticClient.CreateIndex(elastic_indexname, c => c.AddMapping(m => m.Type("_default_").DynamicTemplates(t => t
                                                        .Add(f => f.Name("string_fields").Match("*").MatchMappingType("string").Mapping(ma => ma
                                                            .String(s => s.Index(FieldIndexOption.NotAnalyzed)))))));
                    }
    

    Thanks

    Mukesh Raghuwanshi

提交回复
热议问题