# ComplexSearch

**URL:** <https://discuss.elastic.co/t/complexsearch/105069>\
**Category:** Elasticsearch\
**Created:** [October 24, 2017, 12:44pm UTC](https://discuss.elastic.co/t/complexsearch/105069 "2017-10-24T12:44:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KALPESH\_BADGUJAR](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@KALPESH\_BADGUJAR](https://discuss.elastic.co/u/KALPESH_BADGUJAR)\
**Post date:** [October 24, 2017, 12:44pm UTC](https://discuss.elastic.co/t/complexsearch/105069/1 "2017-10-24T12:44:59Z")

</div>

I have created ElasticSearch index with following mapping. I need to write Complex Search query like find relevant Items on query result. Ex.Find item having price= "100". Get ItemBrand from search result and then find other items having same ItemBrand.(Similar products). Can anyone help me out?

PUT myindex-solvisoft2  
{  
"mappings": {  
"ItemCategory":{  
"properties": {Category":{"type": "text"},"IsActive":{"type": "boolean"},"Comment":{"type": "text" }}  
},

"ItemBrand": {  
"properties": {"Creator": {"type": "keyword"},"DateEffective": {"type": "date"},"DateTerminated": {"type": "date"},"Description": {"type": "text"},  
"IsActive": {"type": "boolean"},"ItemBrand": {"type": "keyword"}}  
},

"Item": {  
"properties": {  
"Comment": {"type": "text"},"Creator": {"type": "keyword"},"DateEffective": {"type": "date"},  
"DateTerminated": {"type": "date"},"IsActive": {"type": "boolean"},"ItemBrand": {"type": "keyword" },  
"ItemDescription": { "type": "text" },"ItemCategory": {"type": "keyword"},"ItemId": {"type": "integer" },  
"Price": {"type": "double" } }  
}  
}  
}

Some what like this =\> Select \* from Item where ItemBrand in (Select ItemBrand from Item where Price = 100 )

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 24, 2017, 5:44pm UTC](https://discuss.elastic.co/t/complexsearch/105069/2 "2017-10-24T17:44:23Z")

</div>

> [@KALPESH\_BADGUJAR](#):
>
> Select \* from Item where ItemBrand in (Select ItemBrand from Item where Price = 100 )

Just do a filter on the price field, then it will return the same thing.

---

<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:** [November 21, 2017, 5:44pm UTC](https://discuss.elastic.co/t/complexsearch/105069/3 "2017-11-21T17:44:34Z")

</div>

Closed on November 21, 2017, 5:44pm UTC

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