Skip to content

Guid properties are not mapped, any reason why not? #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jakejscott opened this issue Jul 29, 2013 · 2 comments
Closed

Guid properties are not mapped, any reason why not? #322

jakejscott opened this issue Jul 29, 2013 · 2 comments

Comments

@jakejscott
Copy link

I want to be able to exact match on a Guid. So I am using the following mapping:

[ElasticProperty(OmitNorms = true, Index = FieldIndexOption.not_analyzed)]
public Guid OrganisationId { get; set; }

But NEST omits Guid types (I think). So I have to use a string for the OrganisationId (which is an easy fix) but I couldn't work out what was going on for a while because my primary key field was also a Guid named 'Id' and that was being picked up by NEST and used as the elastic _id field.

Cheers
Jake

@tystol
Copy link

tystol commented Jul 30, 2013

Just went through the exact same thing.

For .net types that do not match 1:1 with the ES type, you need to explicitly set the ES type. e.g:

[ElasticProperty(Type = FieldType.string_type, OmitNorms = true, Index = FieldIndexOption.not_analyzed)]
public Guid OrganisationId { get; set; }

But I do agree it is misleading due to public Guid Id properties working without any special mapping due to the default 'Id' property name matching.

@jakejscott
Copy link
Author

@ITS-TYSON Oh cool thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants