# Display same document structure on two different way

**URL:** <https://discuss.elastic.co/t/display-same-document-structure-on-two-different-way/22303>\
**Category:** Elasticsearch\
**Created:** [February 20, 2015, 10:02pm UTC](https://discuss.elastic.co/t/display-same-document-structure-on-two-different-way/22303 "2015-02-20T22:02:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnold\_Somogyi](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@Arnold\_Somogyi](https://discuss.elastic.co/u/Arnold_Somogyi)\
**Post date:** [February 20, 2015, 10:02pm UTC](https://discuss.elastic.co/t/display-same-document-structure-on-two-different-way/22303/1 "2015-02-20T22:02:15Z")

</div>

Hi,

I would like to migrate my database tables into elasticsearch. I read the  
first 3 chapter of the Elasticsearch Server, 2nd Edition book but honestly  
I do not know how can I reach my target.

Is it possible to display same document structure on two different way? I  
am giving you an example.

_I have a database scheme with two tables like this:_

## table 1: VEHICLE pk | make | model | description

## 1 | BMV | 116i | Very reliable BMW 1 series for sale

## 2 | Volvo | excavator | EXCAVATOR FOR SALE

## table 2: DETAILS pk | vehicle\_id | key | value

## 1 | 1 | colour | red 2 | 1 | year | 2015 3 | 1 | mileage | 110000

## 4 | 2 | year | 2010 5 | 2 | hours of use | 3600

_I have two sql queries:_  
(1) display the available vehicles  
select v.make, v.model from vehicle v where

(2) generate a tag cloud for the user interface:  
select d.key, count(d.key) from details d where inner join  
vehicle v on v.id = d.vehicle\_id group by d.key

_result of sql query 2:_

- hours of usage (1)
- year (2)
- colour (1)
- milage (1)

So I have created an elasticsearch index like this:  
{  
"settings": {  
"index": {  
"mapping.allow\_type\_wrapper": true  
}  
},  
"mappings": {  
"vehicle": {  
"dynamic": "false",  
"properties": {  
"pk": { "type": "long", "store": "yes", "index": "no",  
"null\_value": -1 },  
"make": { "type": "string", "store": "yes", "index": "analyzed",  
"null\_value": "" },  
"model": { "type": "string", "store": "yes", "index": "analyzed",  
"null\_value": "" },  
"description": { "type": "string", "store": "yes", "index": "analyzed",  
"null\_value": "" },  
"details": {  
"properties": {  
"key": { "type": "string", "store": "yes", "index": "analyzed",  
"null\_value" : "" },  
"value": { "type": "string", "store": "yes", "index": "analyzed",  
"null\_value": "" }  
}  
}  
}  
}  
}  
}

I am able to add documents and query the available vehicles from the  
elasticsearch but I do not know how I can reproduce data for tag cloud with  
elasticsearch.

Could you help me?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d062d153-1cd2-4317-b65a-8106d649565a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d062d153-1cd2-4317-b65a-8106d649565a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:31am UTC](https://discuss.elastic.co/t/display-same-document-structure-on-two-different-way/22303/2 "2017-07-06T00:31:06Z")

</div>

Closed on July 6, 2017, 12:31am UTC


