Generic method for Document Properties creation


(Arpan Sahoo) #1

Hi,
For multi fields creation in NEST, I am using below approach (ElasticSearchProperties - is a class file having City, Email as strings) :-
.Mappings(ms => ms.Map(m1 => m1
.AutoMap()
.AllField(af => af.Enabled(false))
.Properties(p => p
.Text(t => t
.Name(n => n.City)
.Index(false)
.CopyTo(c => c.Field("Address"))
)
.Text(t => t
.Name(n => n.Email)
.Fields(f => f
.Text(tt => tt
.Name("Prefix")
.Analyzer(BasicPrefixAnalyzer)
.SearchAnalyzer(BasicAnalyzer)
)
)
.Analyzer(BasicAnalyzer)
)
)
)
)

  1. Is there a way by which I can create multifields (or sub fields, for example "Prefix" field above) using POCO?
  2. Is there a way of creating a Generic method, to which I will pass attribute and it will create me properties for a document. Not necessary the above structure, it may be anything (like Sub field as Keyword etc etc)?

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.