Nested attribute on List<string> generating unwanted properties
See original GitHub issueNEST/Elasticsearch.Net version: 2.3.3
Elasticsearch version: 2.3.2
Description of the problem including expected versus actual behavior:
I have a mapping for a list<string> set with the Nested attribute and it’s creating unwanted properties on the ES mapping.
[Nested(IncludeInParent=true)]
public List<String> raw_amenities { get; set; }
yields
raw_amenities": {
"type": "nested",
"include_in_parent": true,
"properties": {
"chars": {
"type": "string"
},
"length": {
"type": "integer"
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Typescript: Omit nested property
3 Answers. First, Omit attributeValues , then add it back with properties removed.
Read more >How to include nested properties is featuredProperties?
To work around this, first create a top-level property for the state and add it as a featured property: let PersonSchema = coda.makeObjectSchema ......
Read more >Work with nested attributes - AWS SDK for Java 2.x
Work with nested attributes. A nested attribute in DynamoDB is embedded in another attribute. Examples are list elements and map entries.
Read more >Csvhelper nested objects. Ignore() on the nested property, bu
Csvhelper nested objects. Ignore() on the nested property, but I think this is not expected behavior. Generic. Nested object initializers elegantly solve ...
Read more >Lists and Tuples in Python
Lists can contain any arbitrary objects. List elements can be accessed by index. Lists can be nested to arbitrary depth. Lists are mutable....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to follow up on what @gmarz has said, you would want to map it as a string type
in fact, if you don’t need to set any other properties for the type e.g. a different analyzer, not analyzed, etc. then you don’t even need the attribute applied, just calling
AutoMap()
will infer astring
type mapping forList<string>
. With Elasticsearch mappings, there is no distinction between a single property type and a collection property type i.e.Both
Amenity
andAmenities
would be mapped asstring
data type in Elasticsearch.Now, if you were dealing with say a
List<Amenity>
whereAmenity
type wasthen the default inferred mapping for this would be
object
. This is fine for some scenarios, but withobject
mapping, the association betweenName
andAdded
for a givenAmenity
instance is not stored in the inverted index. For example, imagine the following amenities are indexed for aHousehold
documentif
Amenities
is mapped as anobject
type, a search forName="electricity"
andAdded=new DateTime(2016, 1, 8)
would return the document as a match. IfAmenities
is mapped as anested
type however, the document would not be a match.I hope that helps explain the difference.
Closing this before we attempt something too clever 😄 we’d have to unpack
PropertyType
see if itsIEnumerable<T>
then check if T is a reference type all for a small gain.