# Conditional query

**URL:** https://discuss.elastic.co/t/conditional-query/15126
**Category:** Elasticsearch
**Created:** [January 7, 2014, 2:03pm UTC](https://discuss.elastic.co/t/conditional-query/15126 "2014-01-07T14:03:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![13efan](https://avatars.discourse-cdn.com/v4/letter/1/91b2a8/32.png) [@13efan](https://discuss.elastic.co/u/13efan)
#### Post date: [January 7, 2014, 2:03pm UTC](https://discuss.elastic.co/t/conditional-query/15126/1 "2014-01-07T14:03:29Z")

</div>

Hello guys,

I want first to apologize for my bad english.

I need your help to build a conditionnal query.

I have documents with 3 information : name, descrption and type  
If user search "ba", i need to find :  
all doc with type 1 and contains "ba" in name AND all doc with type 2 and 3 and contains "ba" in description.

Exemple  
Name Descrption type Id  
Joba fooo 1 0  
Jule baba 2 1  
John haba 3 2  
Tarf baba 1 3

The request must give me the doc with id 0, 1, 2 but not 3

I really need your help

---

<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, 1:58am UTC](https://discuss.elastic.co/t/conditional-query/15126/2 "2017-07-06T01:58:03Z")

</div>


