# Advice on best approach to implement Compass component/reference idiom

**URL:** <https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340>\
**Category:** Elasticsearch\
**Created:** [May 4, 2011, 7:53am UTC](https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340 "2011-05-04T07:53:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jondow](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jondow/32/2111_2.png) [@Jondow](https://discuss.elastic.co/u/Jondow)\
**Post date:** [May 4, 2011, 7:53am UTC](https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340/1 "2011-05-04T07:53:06Z")

</div>

I'm trying to get my head around how to model the Compass component/  
reference concept. Basically I have a whole bunch of Device objects  
that are associated with many Software objects which are the result of  
an audit done on a machine, and I want to be able to search for  
Software objects, but get Device objects back as the results of my  
search. With Compass, you'd make Software a component of Device and be  
on your way.

What would be the best strategy to accomplish this with ES? Would I  
need to do some form of custom mapping?

Regards,  
Darryl

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 4, 2011, 8:13am UTC](https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340/2 "2011-05-04T08:13:01Z")

</div>

You will simply need to create the json and represent it the way you want. Comparing the component mapping, then Software will be inner objects in the Device object. Use jackson to easily convert your domain model to json.  
On Wednesday, May 4, 2011 at 10:53 AM, Jondow wrote:

> I'm trying to get my head around how to model the Compass component/  
> reference concept. Basically I have a whole bunch of Device objects  
> that are associated with many Software objects which are the result of  
> an audit done on a machine, and I want to be able to search for  
> Software objects, but get Device objects back as the results of my  
> search. With Compass, you'd make Software a component of Device and be  
> on your way.
> 
> What would be the best strategy to accomplish this with ES? Would I  
> need to do some form of custom mapping?
> 
> Regards,  
> Darryl

---

<div class="post-metadata">

**Author:** ![Jondow](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jondow/32/2111_2.png) [@Jondow](https://discuss.elastic.co/u/Jondow)\
**Post date:** [May 4, 2011, 8:46am UTC](https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340/3 "2011-05-04T08:46:51Z")

</div>

Thanks Shay.

So no custom mapping necessary. Defaults will suffice yeah?

On May 4, 10:13 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> You will simply need to create the json and represent it the way you want. Comparing the component mapping, then Software will be inner objects in the Device object. Use jackson to easily convert your domain model to json.
> 
> On Wednesday, May 4, 2011 at 10:53 AM, Jondow wrote:
> 
> > I'm trying to get my head around how to model the Compass component/  
> > reference concept. Basically I have a whole bunch of Device objects  
> > that are associated with many Software objects which are the result of  
> > an audit done on a machine, and I want to be able to search for  
> > Software objects, but get Device objects back as the results of my  
> > search. With Compass, you'd make Software a component of Device and be  
> > on your way.
> 
> > What would be the best strategy to accomplish this with ES? Would I  
> > need to do some form of custom mapping?
> 
> > Regards,  
> > Darryl

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 4, 2011, 8:47am UTC](https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340/4 "2011-05-04T08:47:54Z")

</div>

You mean using dynamic mappings in elasticsearch? Yes, assuming the defaults are good enough. They automatically handle inner (json) objects.  
On Wednesday, May 4, 2011 at 11:46 AM, Jondow wrote:

> Thanks Shay.
> 
> So no custom mapping necessary. Defaults will suffice yeah?
> 
> On May 4, 10:13 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > You will simply need to create the json and represent it the way you want. Comparing the component mapping, then Software will be inner objects in the Device object. Use jackson to easily convert your domain model to json.
> > 
> > On Wednesday, May 4, 2011 at 10:53 AM, Jondow wrote:
> > 
> > > I'm trying to get my head around how to model the Compass component/  
> > > reference concept. Basically I have a whole bunch of Device objects  
> > > that are associated with many Software objects which are the result of  
> > > an audit done on a machine, and I want to be able to search for  
> > > Software objects, but get Device objects back as the results of my  
> > > search. With Compass, you'd make Software a component of Device and be  
> > > on your way.
> > 
> > > What would be the best strategy to accomplish this with ES? Would I  
> > > need to do some form of custom mapping?
> > 
> > > Regards,  
> > > Darryl

---

<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:** [July 6, 2017, 4:07am UTC](https://discuss.elastic.co/t/advice-on-best-approach-to-implement-compass-component-reference-idiom/4340/5 "2017-07-06T04:07:00Z")

</div>

Closed on July 6, 2017, 4:07am UTC


