# Search query to return docs based on conditions inside the doc

**URL:** https://discuss.elastic.co/t/search-query-to-return-docs-based-on-conditions-inside-the-doc/12001
**Category:** Elasticsearch
**Created:** [May 17, 2013, 1:48am UTC](https://discuss.elastic.co/t/search-query-to-return-docs-based-on-conditions-inside-the-doc/12001 "2013-05-17T01:48:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shgeorge](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@shgeorge](https://discuss.elastic.co/u/shgeorge)
#### Post date: [May 17, 2013, 1:48am UTC](https://discuss.elastic.co/t/search-query-to-return-docs-based-on-conditions-inside-the-doc/12001/1 "2013-05-17T01:48:51Z")

</div>

Hi  
I have a usecase where the conditions for returning the document is  
predefined in the doc. At query time these conditions are unknown. Is there  
a way to evaluate this before returning the search results.

Eg: document with id b1 should be returned when type == shoes and temp \>  
80 while  
document b2 should be returned when type == shoes and temp == 80 and age \<  
20

Is it possible to construct queries to return the docs that match the  
predefined conditions?  
Appreciate any suggestion

Thanks  
Sheeba

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [May 17, 2013, 10:59am UTC](https://discuss.elastic.co/t/search-query-to-return-docs-based-on-conditions-inside-the-doc/12001/2 "2013-05-17T10:59:36Z")

</div>

Hi Sheeba

Only by marking docs b1 and b2 with some other field, like a category or  
something, eg when type==shoes and type==80, then return docs of category  
'foo'. So you'd need to store category 'foo' in the doc

clint

On 17 May 2013 03:48, Sheeba George [sheeba.george@gmail.com](mailto:sheeba.george@gmail.com) wrote:

> Hi  
> I have a usecase where the conditions for returning the document is  
> predefined in the doc. At query time these conditions are unknown. Is there  
> a way to evaluate this before returning the search results.
> 
> Eg: document with id b1 should be returned when type == shoes and temp \>  
> 80 while  
> document b2 should be returned when type == shoes and temp == 80 and age \<  
> 20
> 
> Is it possible to construct queries to return the docs that match the  
> predefined conditions?  
> Appreciate any suggestion
> 
> Thanks  
> Sheeba
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:36am UTC](https://discuss.elastic.co/t/search-query-to-return-docs-based-on-conditions-inside-the-doc/12001/3 "2017-07-06T02:36:07Z")

</div>


