elasticsearch


Saving C# enumeration as string instead of int in ElasticSearch 5


I used to have String attribute on class properties of type enumeration in Elastic Search 2.0 so that enumeration value to be stored as string rather than integer:
public enum PaperType
{
A4 = 0,
A3 = 1
}
and class to be stored as document in ElasticSearch
[ElasticsearchType(Name = "Paper")]
public class Paper
{
[String(Store = false, Index = FieldIndexOption.Analyzed)]
public string Name { get; set; }
[String(Store = false, Index = FieldIndexOption.Analyzed)]
public PaperType Type { get; set; }
}
So in Type would be stored as A3 or A4 rather than 0 or 1.
in ElasticSearch 5, these attributes have changed,
How could I achieve the same behavior in ElasticSearch 5 or what attribute and how it should be?
Thanks
Take a look at attribute mapping in the documentation; you're likely looking to map them as Keyword types.
If you want to save all enum as string, you can add the Json.Net StringEnumConverter to the JsonSerializerSettings to use for any type that is an enum.

Related Links

In logstash/ElasticSearch/Kibana, how do I augment records following a particular stateful request?
How to know which shard is overloaded in Elasticsearch?
ElasticSearch - searching different doc_types with the same field name but different analyzers
ELK Type Conversion - Not a number but a string
How to get the definitiion of a search analyzer of an index in elasticsearch
ElasticSearch query using match or term?
How to combine aggregations in ElasticSearch/Kibana?
ElasticSerach cluster performance
Nxlog unable to send eventlog after certain time
Sort elasticsearch search hits by document count
Elastic search date range max, min date
Elastic search river mongodb _meta returning action not found error
Seeing many open Elasticsearch connections even after using singleton pattern
What would be a good approach for sending logs from multiple servers a centralized logging server?
does elasticsearch support queries of queries?
Data modelling with elastic search

Categories

HOME
magento2
knockout.js
macos-sierra
matrix
xcode
shinyapps
applescript
dafny
google-play-services
amp
scheduler
responsive-design
tfs2010
gtk
migrate
scrape
alljoyn
responsivevoice
live-streaming
ex
pushdown-automaton
google-tasks-api
closures
cocos2d-android
salt-cloud
raml
pe
uislider
backendless
pdf.js
router
window-managers
multi-dimensional-scaling
jackrabbit-oak
sendmessage
sales
amazon-iam
copy-protection
google-play-developer-api
listjs
ms-media-foundation
spring-rabbitmq
amazon-kms
wdk
microkernel
jqgrid-asp.net
destroy
common-table-expression
liteide
jgrapht
phppgadmin
punctuation
maven-jaxb2-plugin
mura
nivo-slider
deedle
wikimapia
business-rules
email-injection
streamwriter
libharu
logical
jsf-2.3
nvda
dpkg
android-4.2-jelly-bean
yii2-model
odp.net-managed
adjacency-list
psd
webgrind
openshift-cartridge
featuretoggle
espresso
alwayson
kotlin-android-extensions
mutators
maven-shade-plugin
datagridcomboboxcolumn
device-admin
smacss
igor
git-reset
lsa
django-settings
sensormanager
apache-shindig
spiral
android-authenticator
xalan
playorm
audiotoolbox
android-dialog
jdom
liveconnect
microblogging
qt-mobility
winsxs
mediacontroller
directshow.net
servlet-container
bll
pyjamas
aggregator
spring-modules
gtktextview
objectinstantiation
synthesizer

Resources

Encrypt Message