# How to store objects which are shared for another objects?

**URL:** <https://discuss.elastic.co/t/how-to-store-objects-which-are-shared-for-another-objects/209326>\
**Category:** Elasticsearch\
**Created:** [November 25, 2019, 2:31pm UTC](https://discuss.elastic.co/t/how-to-store-objects-which-are-shared-for-another-objects/209326 "2019-11-25T14:31:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SeminDM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/semindm/32/58395_2.png) [@SeminDM](https://discuss.elastic.co/u/SeminDM)\
**Post date:** [November 25, 2019, 2:31pm UTC](https://discuss.elastic.co/t/how-to-store-objects-which-are-shared-for-another-objects/209326/1 "2019-11-25T14:31:28Z")

</div>

Hello!  
I have object of 'A' which have references to rarely changed object of 'RarelyChanged' (for example, user context) and frequently changed object of 'FrequentlyChanged'. "Rarely changed" means the many 'A' objects will have reference to same 'RarelyChanged ' object. In another words 'RarelyChanged' objects are shared for 'A' objects.

```auto
public class A
{
   public string Name { get; set; }
   public RarelyChanged Rarely { get; set; }
   public FrequentlyChanged Frequently { get; set; }
}

public class RarelyChanged
{
   public string Login { get; set; }
   public string Address { get; set; }
   // many others props
}

public class FrequentlyChanged
{
   public Dictionary<string, object> Data { get; set; }
}

```

I don't want to store data of 'RarelyChanged' for every 'A' object and I want to filter, sort whole document ('A') by 'RarelyChanged' props.

How to store 'RarelyChanged' objects in the right way in Elastic Search?

I know about parent/child relations and nested object. But is this not my case, right?

Thank you!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 27, 2019, 6:25am UTC](https://discuss.elastic.co/t/how-to-store-objects-which-are-shared-for-another-objects/209326/2 "2019-11-27T06:25:17Z")

</div>

> [@SeminDM](#):
>
> I don't want to store data of 'RarelyChanged' for every 'A' object and I want to filter, sort whole document ('A') by 'RarelyChanged' props.

Why? When working with a non-relational system this is a very common type of de-normalization. In this case I would say it is a solution worth looking into.

---

<div class="post-metadata">

**Author:** ![SeminDM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/semindm/32/58395_2.png) [@SeminDM](https://discuss.elastic.co/u/SeminDM)\
**Post date:** [November 27, 2019, 9:25am UTC](https://discuss.elastic.co/t/how-to-store-objects-which-are-shared-for-another-objects/209326/3 "2019-11-27T09:25:44Z")

</div>

@Christian_Dahlqvist Shared objects might be:

1. heavy
2. same for many (millions) 'A' objects.  
I want consume memory more optimally.  
One thing: I won't update documents at all (read/write/delete only)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 25, 2019, 9:25am UTC](https://discuss.elastic.co/t/how-to-store-objects-which-are-shared-for-another-objects/209326/4 "2019-12-25T09:25:49Z")

</div>

Closed on December 25, 2019, 9:25am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
