Skip to content
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

Mapping - cannot set a field to not be analized #19

Closed
ionut-rosoiu opened this issue Feb 21, 2012 · 3 comments
Closed

Mapping - cannot set a field to not be analized #19

ionut-rosoiu opened this issue Feb 21, 2012 · 3 comments

Comments

@ionut-rosoiu
Copy link

I cannot get a field to not be analyzed:

class Post
{
[ElasticProperty(Index = FieldIndexOption.not_analyzed)]
public string Tag { get; set; }
}

@ionut-rosoiu
Copy link
Author

Ok, common manifestation of PEBKAC, forgot to persist the mapping.

It doesn't work though for List< string > properties and the solution is to create a custom mapping using TypeMappingProperty.

@Mpdreamz
Copy link
Member

Hah i had to google pebkac but glad to hear you got it working. Could you elaborate on your solution with a list of strings? Sounds like something worthy to be wikified :)

@ionut-rosoiu
Copy link
Author

It was simple, really. I just wanted to have a List< string > propName not indexed, so I had to create an explicit type mapping first:

class Post
{
    [ElasticProperty(Name="tags", Index=FieldIndexOption.not_analyzed)]
    public List<string> Tags { get; set; }
}
var stringField = new TypeMappingProperty
{
    Type = "string",
    Index = "not_analyzed"
};

myMapping.Properties.Add("tags", stringField);

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