-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
I know that null value handling is kind of an all or nothing thing with JSON.NET, but I've come across an interesting issue. For things like update and index I want to include null values, as they pertain to fields in documents I'm interested in. In my case, I'm passing in both POCOs and dictionaries depending on what I want to do and I want the null values to be included in both. I know that for POCOs there is JsonPropertyAttribute to fix this. I not aware of something similar dictionaries. For searching, the null value stuff gets in the way. For example, with I have null values included, the library generates this for one search I'm doing:
{
"timeout": null,
"from": 0,
"size": 200,
"explain": null,
"version": null,
"track_scores": null,
"min_score": null,
"indices_boost": null,
"sort": [{
"date_created": {
"ignore_unmapped": null,
"missing": null,
"order": "desc",
"mode": null,
"nested_filter": null,
"nested_path": null
}
}],
"facets": null,
"suggest": null,
"highlight": null,
"rescore": null,
"fields": null,
"script_fields": null,
"_source": null,
"aggs": null,
"query": {
"bool": null,
"match_all": null,
"term": null,
"wildcard": null,
"prefix": null,
"boosting": null,
"ids": null,
"custom_score": null,
"custom_filters_score": null,
"custom_boost_factor": null,
"constant_score": null,
"dis_max": null,
"filtered": {
"query": {
"bool": null,
"match_all": {
"boost": null,
"norm_field": null
},
"term": null,
"wildcard": null,
"prefix": null,
"boosting": null,
"ids": null,
"custom_score": null,
"custom_filters_score": null,
"custom_boost_factor": null,
"constant_score": null,
"dis_max": null,
"filtered": null,
"multi_match": null,
"match": null,
"fuzzy": null,
"geo_shape": null,
"common": null,
"terms": null,
"range": null,
"regexp": null,
"has_child": null,
"has_parent": null,
"span_term": null,
"flt": null,
"simple_query_string": null,
"query_string": null,
"mlt": null,
"span_first": null,
"span_or": null,
"span_near": null,
"span_not": null,
"span_multi": null,
"top_children": null,
"nested": null,
"indices": null,
"function_score": null,
"template": null
},
"filter": {
"bool": null,
"exists": null,
"missing": null,
"ids": null,
"geo_bounding_box": null,
"geo_distance": null,
"geohash_cell": null,
"geo_distance_range": null,
"geo_polygon": null,
"geo_shape": null,
"limit": null,
"type": null,
"match_all": null,
"has_child": null,
"has_parent": null,
"range": null,
"prefix": null,
"term": null,
"terms": null,
"fquery": {
"query": {
"bool": {
"must": [{
"bool": null,
"match_all": null,
"term": {
"instanceid": {
"value": "CDR",
"boost": null
}
},
"wildcard": null,
"prefix": null,
"boosting": null,
"ids": null,
"custom_score": null,
"custom_filters_score": null,
"custom_boost_factor": null,
"constant_score": null,
"dis_max": null,
"filtered": null,
"multi_match": null,
"match": null,
"fuzzy": null,
"geo_shape": null,
"common": null,
"terms": null,
"range": null,
"regexp": null,
"has_child": null,
"has_parent": null,
"span_term": null,
"flt": null,
"simple_query_string": null,
"query_string": null,
"mlt": null,
"span_first": null,
"span_or": null,
"span_near": null,
"span_not": null,
"span_multi": null,
"top_children": null,
"nested": null,
"indices": null,
"function_score": null,
"template": null
}, {
"bool": null,
"match_all": null,
"term": {
"archived": {
"value": false,
"boost": null
}
},
"wildcard": null,
"prefix": null,
"boosting": null,
"ids": null,
"custom_score": null,
"custom_filters_score": null,
"custom_boost_factor": null,
"constant_score": null,
"dis_max": null,
"filtered": null,
"multi_match": null,
"match": null,
"fuzzy": null,
"geo_shape": null,
"common": null,
"terms": null,
"range": null,
"regexp": null,
"has_child": null,
"has_parent": null,
"span_term": null,
"flt": null,
"simple_query_string": null,
"query_string": null,
"mlt": null,
"span_first": null,
"span_or": null,
"span_near": null,
"span_not": null,
"span_multi": null,
"top_children": null,
"nested": null,
"indices": null,
"function_score": null,
"template": null
}],
"must_not": null,
"should": null,
"minimum_should_match": null,
"disable_coord": null,
"boost": null
},
"match_all": null,
"term": null,
"wildcard": null,
"prefix": null,
"boosting": null,
"ids": null,
"custom_score": null,
"custom_filters_score": null,
"custom_boost_factor": null,
"constant_score": null,
"dis_max": null,
"filtered": null,
"multi_match": null,
"match": null,
"fuzzy": null,
"geo_shape": null,
"common": null,
"terms": null,
"range": null,
"regexp": null,
"has_child": null,
"has_parent": null,
"span_term": null,
"flt": null,
"simple_query_string": null,
"query_string": null,
"mlt": null,
"span_first": null,
"span_or": null,
"span_near": null,
"span_not": null,
"span_multi": null,
"top_children": null,
"nested": null,
"indices": null,
"function_score": null,
"template": null
},
"_cache": null,
"_name": null,
"_cache_key": null
},
"and": null,
"or": null,
"not": null,
"script": null,
"nested": null,
"regexp": null
}
},
"multi_match": null,
"match": null,
"fuzzy": null,
"geo_shape": null,
"common": null,
"terms": null,
"range": null,
"regexp": null,
"has_child": null,
"has_parent": null,
"span_term": null,
"flt": null,
"simple_query_string": null,
"query_string": null,
"mlt": null,
"span_first": null,
"span_or": null,
"span_near": null,
"span_not": null,
"span_multi": null,
"top_children": null,
"nested": null,
"indices": null,
"function_score": null,
"template": null
},
"filter": null
}In any case, it would be nice to set this per request. Is there anything already available that does this?