Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.38 KB

modeling-documents-with-types.asciidoc

File metadata and controls

37 lines (27 loc) · 1.38 KB

Modeling documents with types

{es} provides search and aggregation capabilities on the documents that it is sent and indexes. These documents are sent as JSON objects within the request body of a HTTP request. It is natural to model documents within the {es} .NET client using POCOs (Plain Old CLR Objects).

This section provides an overview of how types and type hierarchies can be used to model documents.

Default behaviour

The default behaviour is to serialize type property names as camelcase JSON object members.

We can model documents using a regular class (POCO).

include-tagged::{doc-tests-src}/ClientConcepts/Serialization/ModellingDocumentsWithTypesTests.cs[my-document-poco]

We can then index the an instance of the document into {es}.

include-tagged::{doc-tests-src}/ClientConcepts/Serialization/ModellingDocumentsWithTypesTests.cs[usings]
include-tagged::{doc-tests-src}/ClientConcepts/Serialization/ModellingDocumentsWithTypesTests.cs[index-my-document]

The index request is serialized, with the source serializer handling the MyDocument type, serializing the POCO property named StringProperty to the JSON object member named stringProperty.

{
  "stringProperty": "value"
}