I dont know in C# but i have solve this issue in java script.. You can use match and in match you can give operator : or so it will search any of the keyword.
I have tried it and woking perfectly. On 7 May 2015 11:12, "RAJEEV DIBOLIYA" <[email protected]> wrote: > 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 Company Solutions'. I > tried querystring query but it gives me all the records irrespective of > search result. Also i read on the post and found that we have to add some > mappings for the field. I tried 'Not_Analyzed' analyzer on the field but > still it does not worked. > > Here is my code of C# > > var indexDefinition = new RootObjectMapping{ > Properties = new Dictionary<PropertyNameMarker, IElasticType>(), > Name = elastic_newindexname};var notAnalyzedField = new StringMapping{ > Index = FieldIndexOption.NotAnalyzed}; > indexDefinition.Properties.Add("Name", notAnalyzedField); > objElasticClient.DeleteIndex(d => d.Index(elastic_newindexname));var reindex > = objElasticClient.Reindex<dynamic>(r => > r.FromIndex(elastic_oldindexname).ToIndex(elastic_newindexname).Query(q => > q.MatchAll()).Scroll("10s").CreateIndex(i => i.AddMapping<dynamic>(m => > m.InitializeUsing(indexDefinition))));ReindexObserver<dynamic> o = new > ReindexObserver<dynamic>(onError: e => { }); > reindex.Subscribe(o);** > **ISearchResponse<dynamic> ivals = objElasticClient.Search<dynamic>(s => > s.Index(elastic_newindexname).AllTypes().Query(q => q.Term("Name","XYZ > Company Solutions")));** //this gives 0 records > **ISearchResponse<dynamic> ivals1 = objElasticClient.Search<dynamic>(s => > s.Index(elastic_newindexname).AllTypes().Query(q => q.Term(u => > u.OnField("Name").Value("XYZ Company Solutions"))));** //this gives 0 records > **ISearchResponse<dynamic> ivals = objElasticClient.Search<dynamic>(s => > s.Index(elastic_newindexname).AllTypes().Query(@"Name = 'XYZ Company > Solutions'"));** //this gives all records having fields value starting with > "XYZ" > > If anyone have complete example or steps in C# then can you please share > with me? > > -- > You received this message because you are subscribed to the Google Groups > "Couchbase" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Couchbase" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
