# Elastic search query syntax

**URL:** <https://discuss.elastic.co/t/elastic-search-query-syntax/23077>\
**Category:** Elasticsearch\
**Created:** [April 3, 2015, 12:38am UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077 "2015-04-03T00:38:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [April 3, 2015, 12:38am UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077/1 "2015-04-03T00:38:06Z")

</div>

Can some one help me to write queries for below scenarios ?

how to find documents that has united and states but not with in 30 words ?(united  
AND states NOT WITHIN 30 WORDS)?

how to find the documents that has united before america ?(united BEFORE  
america)

how to find the documents that has united followed by america?(united  
FOLLOWEDBY america )

how to find the documents that war and peace near novel or book?(war AND  
peace) NEAR (novel OR book)

Regards,

Nagaraju

--  
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/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [April 3, 2015, 12:46am UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077/2 "2015-04-03T00:46:23Z")

</div>

also please let me know the syntax for below query scenario

how to find the documents with a phrase starts with "united" and ends with  
"states" conatain the term "new york" in between

Regards  
Nagaraju  
908 517 6981

On Thu, Apr 2, 2015 at 8:38 PM, bvnrwork [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com) wrote:

> Can some one help me to write queries for below scenarios ?
> 
> how to find documents that has united and states but not with in 30 words  
> ?(united AND states NOT WITHIN 30 WORDS)?
> 
> how to find the documents that has united before america ?(united BEFORE  
> america)
> 
> how to find the documents that has united followed by america?(united  
> FOLLOWEDBY america )
> 
> how to find the documents that war and peace near novel or book?(war AND  
> peace) NEAR (novel OR book)
> 
> Regards,
> 
> Nagaraju
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAFtuXXKNAGkQdQhvDVcvgYZEyxurbCFyds%3DMWmCk2c07GPLr5w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFtuXXKNAGkQdQhvDVcvgYZEyxurbCFyds%3DMWmCk2c07GPLr5w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [April 3, 2015, 5:55am UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077/3 "2015-04-03T05:55:45Z")

</div>

Can some one help me writing above mentioned search queries or at-least  
reference where I can look for examples

Regards  
Nagaraju  
908 517 6981

On Thu, Apr 2, 2015 at 8:46 PM, buddarapu nagaraju [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com)  
wrote:

> also please let me know the syntax for below query scenario
> 
> how to find the documents with a phrase starts with "united" and ends  
> with "states" conatain the term "new york" in between
> 
> Regards  
> Nagaraju  
> 908 517 6981
> 
> On Thu, Apr 2, 2015 at 8:38 PM, bvnrwork [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com) wrote:
> 
> > Can some one help me to write queries for below scenarios ?
> > 
> > how to find documents that has united and states but not with in 30 words  
> > ?(united AND states NOT WITHIN 30 WORDS)?
> > 
> > how to find the documents that has united before america ?(united BEFORE  
> > america)
> > 
> > how to find the documents that has united followed by america?(united  
> > FOLLOWEDBY america )
> > 
> > how to find the documents that war and peace near novel or book?(war AND  
> > peace) NEAR (novel OR book)
> > 
> > Regards,
> > 
> > Nagaraju
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAFtuXX%2B6d\_EfrnYNN320x%2BzLumCNjkqjDdSvX%3DAENvXCC%2B3Ltg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFtuXX%2B6d_EfrnYNN320x%2BzLumCNjkqjDdSvX%3DAENvXCC%2B3Ltg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [April 4, 2015, 3:52am UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077/4 "2015-04-04T03:52:22Z")

</div>

Can some one help me getting these query syntax for below queries

how to find documents that has united and states but not with in 30 words ?(united  
AND states NOT WITHIN 30 WORDS)?

how to find the documents that has united before america ?(united BEFORE  
america)

how to find the documents that has united followed by america?(united  
FOLLOWEDBY america )

how to find the documents that war and peace near novel or book?(war AND  
peace) NEAR (novel OR book)

On Friday, 3 April 2015 01:55:57 UTC-4, bvnrwork wrote:

> Can some one help me writing above mentioned search queries or at-least  
> reference where I can look for examples
> 
> Regards  
> Nagaraju  
> 908 517 6981
> 
> On Thu, Apr 2, 2015 at 8:46 PM, buddarapu nagaraju [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com)  
> wrote:
> 
> > also please let me know the syntax for below query scenario
> > 
> > how to find the documents with a phrase starts with "united" and ends  
> > with "states" conatain the term "new york" in between
> > 
> > Regards  
> > Nagaraju  
> > 908 517 6981
> > 
> > On Thu, Apr 2, 2015 at 8:38 PM, bvnrwork [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com) wrote:
> > 
> > > Can some one help me to write queries for below scenarios ?
> > > 
> > > how to find documents that has united and states but not with in 30  
> > > words ?(united AND states NOT WITHIN 30 WORDS)?
> > > 
> > > how to find the documents that has united before america ?(united  
> > > BEFORE america)
> > > 
> > > how to find the documents that has united followed by america?(united  
> > > FOLLOWEDBY america )
> > > 
> > > how to find the documents that war and peace near novel or book?(war AND  
> > > peace) NEAR (novel OR book)
> > > 
> > > Regards,
> > > 
> > > Nagaraju
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe).  
> > > To unsubscribe from this group and all its topics, 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/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/d9776143-164a-4343-bbf9-5427a4c4739f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d9776143-164a-4343-bbf9-5427a4c4739f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [April 6, 2015, 9:42pm UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077/5 "2015-04-06T21:42:03Z")

</div>

hi ,

Can some body help me getting search syntax for above mentioned queries in  
previous emails

Regards  
Nagaraju  
908 517 6981

On Fri, Apr 3, 2015 at 11:52 PM, bvnrwork [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com) wrote:

> Can some one help me getting these query syntax for below queries
> 
> how to find documents that has united and states but not with in 30 words  
> ?(united AND states NOT WITHIN 30 WORDS)?
> 
> how to find the documents that has united before america ?(united BEFORE  
> america)
> 
> how to find the documents that has united followed by america?(united  
> FOLLOWEDBY america )
> 
> how to find the documents that war and peace near novel or book?(war AND  
> peace) NEAR (novel OR book)
> 
> On Friday, 3 April 2015 01:55:57 UTC-4, bvnrwork wrote:
> 
> > Can some one help me writing above mentioned search queries or at-least  
> > reference where I can look for examples
> > 
> > Regards  
> > Nagaraju  
> > 908 517 6981
> > 
> > On Thu, Apr 2, 2015 at 8:46 PM, buddarapu nagaraju \<[budda08nitt@gmail.com](mailto:budda08nitt@gmail.com)
> > 
> > > wrote:
> > 
> > > also please let me know the syntax for below query scenario
> > > 
> > > how to find the documents with a phrase starts with "united" and ends  
> > > with "states" conatain the term "new york" in between
> > > 
> > > Regards  
> > > Nagaraju  
> > > 908 517 6981
> > > 
> > > On Thu, Apr 2, 2015 at 8:38 PM, bvnrwork [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com) wrote:
> > > 
> > > > Can some one help me to write queries for below scenarios ?
> > > > 
> > > > how to find documents that has united and states but not with in 30  
> > > > words ?(united AND states NOT WITHIN 30 WORDS)?
> > > > 
> > > > how to find the documents that has united before america ?(united  
> > > > BEFORE america)
> > > > 
> > > > how to find the documents that has united followed by america?(united  
> > > > FOLLOWEDBY america )
> > > > 
> > > > how to find the documents that war and peace near novel or book?(war  
> > > > AND peace) NEAR (novel OR book)
> > > > 
> > > > Regards,
> > > > 
> > > > Nagaraju
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > topic/elasticsearch/rqDipmvYjyU/unsubscribe.  
> > > > To unsubscribe from this group and all its topics, 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/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/074d907d-1e87-4c57-9933-227e407fd0cb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rqDipmvYjyU/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/d9776143-164a-4343-bbf9-5427a4c4739f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d9776143-164a-4343-bbf9-5427a4c4739f%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/d9776143-164a-4343-bbf9-5427a4c4739f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d9776143-164a-4343-bbf9-5427a4c4739f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAFtuXXLzQtLCtB93B03VKUr97TEGGWjYhCFGZGxHvBP7ugkXDA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFtuXXLzQtLCtB93B03VKUr97TEGGWjYhCFGZGxHvBP7ugkXDA%40mail.gmail.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:21am UTC](https://discuss.elastic.co/t/elastic-search-query-syntax/23077/6 "2017-07-06T00:21:23Z")

</div>


