Hello,
I'm VERY new to ES and I mainly use C# so I downloaded the NEST .net API.
I indexed an object (named "Nation" -> ES type "Nations") which has the
following properties for example: Name, ISO.
When I look at the _source in ES I see it turned all my properties to
lowercase: name. iSO.
So I read a bit on NEST and saw they have an attribute for the property:
- [ElasticProperty(Name = "Name")]
public stirng Name { get; set; }
- [ElasticProperty(Name = "ISO")]
public stirng ISO { get; set; }
But this is annoying since it's on the prop level, so I have to set it for
all the hundreds of props I have in the project.
Isn't there an easier way to tel ES to stop lower-casing my fields?
Thanks.
Liron
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Liron,
Nests default behavior is to camelCase all the property names, you can
easily override this globally by setting a custom TypeNameInferrer method.
var uri = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(uri)
.SetDefaultIndex("mydefaultindex")
.SetTypeNameInferrer(i=>i);
var client = new ElasticClient(settings);
This leaves the original propertynames untouched. Be aware though that an
explicit ElasticProperty Annotation always takes precedence so remove the
annotations.
See also: http://nest.azurewebsites.net/concepts/connecting.html
On Thursday, August 22, 2013 1:26:55 PM UTC+2, Liron Cohen wrote:
Hello,
I'm VERY new to ES and I mainly use C# so I downloaded the NEST .net API.
I indexed an object (named "Nation" -> ES type "Nations") which has the
following properties for example: Name, ISO.
When I look at the _source in ES I see it turned all my properties to
lowercase: name. iSO.
So I read a bit on NEST and saw they have an attribute for the property:
- [ElasticProperty(Name = "Name")]
public stirng Name { get; set; }
- [ElasticProperty(Name = "ISO")]
public stirng ISO { get; set; }
But this is annoying since it's on the prop level, so I have to set it
for all the hundreds of props I have in the project.
Isn't there an easier way to tel ES to stop lower-casing my fields?
Thanks.
Liron
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Thanks. But I meant the properties' names. no the object (/type) name.
The correct syntax is:
.SetDefaultTypeNameInferrer(p => p.Name);
So .net' Location object turn into Location Type in ES.
Any thought as to how to make something similar for properties?
Thanks again,
Liron
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Argh, serves me right for writing code from the top of my head before the
first cuppa.
See: How to disable camelCase ? · Issue #275 · elastic/elasticsearch-net · GitHub
I'll be sure to improve the API for this in the next version!
On Fri, Aug 23, 2013 at 3:47 PM, Liron Cohen cliron1@gmail.com wrote:
Thanks. But I meant the properties' names. no the object (/type) name.
The correct syntax is:
.SetDefaultTypeNameInferrer(p => p.Name);
So .net' Location object turn into Location Type in ES.
Any thought as to how to make something similar for properties?
Thanks again,
Liron
--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/kPjclYNfdGg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Ohh... You're a life saver.
I almost gave up on this...
Perfect.
So just to keep it all in this thread, here is the final solution:
var settings = new ConnectionSettings(new Uri("localhost/9200"));
settings
.SetDefaultTypeNameInferrer(p => p.Name);
var client = new ElasticClient(settings);
client.ModifyJsonSerializationSettings(s =>
s.ContractResolver = new Nest.Resolvers.ElasticResolver(settings);
);
Thanks.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.