# Unable to search for text

**URL:** <https://discuss.elastic.co/t/unable-to-search-for-text/9275>\
**Category:** Elasticsearch\
**Created:** [October 8, 2012, 3:55pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275 "2012-10-08T15:55:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 8, 2012, 3:55pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/1 "2012-10-08T15:55:51Z")

</div>

Hello All,

I am trying to create a query to filter based on the date range provided,  
search for specific ID and also with some "search text or some search  
keywords"

I am able to fetch the records with the date range and ID provided, but  
unable to search for any text within these records:

curl -XGET '[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)' -d '{ "query"  
: {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to" :  
"2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
{"Timestamp":{"order":"desc"}}}'

The above query is working fine , but how do I add TEXT search to the above  
query so that I can query based on smoe sample keywords and date range and  
look for specific ID .

For example if I wanted to search for "Elastic" , "MyName" and "Someother  
keyword"(wanted to perform single and mulitple keyword search) in the  
"\_source" field with in the documents.

Many Thanks in Advance 🙂

Regards,  
Shannu.

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 8, 2012, 4:05pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/2 "2012-10-08T16:05:42Z")

</div>

Hi Shannu,

If I understand you correctly, you simply want to add more queries to the  
existing range query? You can combine queries together using a boolean  
query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

The range query would be one clause and your text search would be another  
clause that are "joined" together using a boolean query.

If you choose to use a filter instead, there is a boolean filter.

Cheers,

Ivan

On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukhaveeranki@gmail.com](mailto:shanmukhaveeranki@gmail.com) wrote:

> Hello All,
> 
> I am trying to create a query to filter based on the date range provided,  
> search for specific ID and also with some "search text or some search  
> keywords"
> 
> I am able to fetch the records with the date range and ID provided, but  
> unable to search for any text within these records:
> 
> curl -XGET '[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)' -d '{  
> "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to" :  
> "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> {"Timestamp":{"order":"desc"}}}'
> 
> The above query is working fine , but how do I add TEXT search to the  
> above query so that I can query based on smoe sample keywords and date  
> range and look for specific ID .
> 
> For example if I wanted to search for "Elastic" , "MyName" and "Someother  
> keyword"(wanted to perform single and mulitple keyword search) in the  
> "\_source" field with in the documents.
> 
> Many Thanks in Advance 🙂
> 
> Regards,  
> Shannu.
> 
> --

--

---

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 8, 2012, 4:23pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/3 "2012-10-08T16:23:17Z")

</div>

Hey Ivan ,

thanks a lot for the reply.

I am a newbie and struggling to work out this bit.

Do u mind sending me a sample query for single & multiple text search and  
boolean query to combine range query and the text please.

That will be very helpful.

Regards,  
Shannu.

On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:

> Hi Shannu,
> 
> If I understand you correctly, you simply want to add more queries to the  
> existing range query? You can combine queries together using a boolean  
> query:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> 
> The range query would be one clause and your text search would be another  
> clause that are "joined" together using a boolean query.
> 
> If you choose to use a filter instead, there is a boolean filter.
> 
> Cheers,
> 
> Ivan
> 
> On Mon, Oct 8, 2012 at 8:55 AM, shannu \<[shanmukh...@gmail.com](mailto:shanmukh...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello All,
> > 
> > I am trying to create a query to filter based on the date range provided,  
> > search for specific ID and also with some "search text or some search  
> > keywords"
> > 
> > I am able to fetch the records with the date range and ID provided, but  
> > unable to search for any text within these records:
> > 
> > curl -XGET '[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)' -d '{  
> > "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to" :  
> > "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > {"Timestamp":{"order":"desc"}}}'
> > 
> > The above query is working fine , but how do I add TEXT search to the  
> > above query so that I can query based on smoe sample keywords and date  
> > range and look for specific ID .
> > 
> > For example if I wanted to search for "Elastic" , "MyName" and "Someother  
> > keyword"(wanted to perform single and mulitple keyword search) in the  
> > "\_source" field with in the documents.
> > 
> > Many Thanks in Advance 🙂
> > 
> > Regards,  
> > Shannu.
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 8, 2012, 8:49pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/4 "2012-10-08T20:49:55Z")

</div>

The page I linked to already has an example. Here is another example with  
your query, except with an added boolean query with a trivial text query.

{  
"query": {  
"bool": {  
"must": {  
"range": {  
"Date": {  
"from": "2012-10-03T09:00:00",  
"to": "2012-10-03T14:00:00"  
}  
}  
},  
"must": {  
"text": {  
"\_all": "elastic"  
}  
}  
}  
},  
"filter": {  
"term": {  
"ID": "123"  
}  
},  
"sort": {  
"Timestamp": {  
"order": "desc"  
}  
}  
}

On Mon, Oct 8, 2012 at 9:23 AM, shannu [shanmukhaveeranki@gmail.com](mailto:shanmukhaveeranki@gmail.com) wrote:

> Hey Ivan ,
> 
> thanks a lot for the reply.
> 
> I am a newbie and struggling to work out this bit.
> 
> Do u mind sending me a sample query for single & multiple text search and  
> boolean query to combine range query and the text please.
> 
> That will be very helpful.
> 
> Regards,  
> Shannu.
> 
> On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:
> 
> > Hi Shannu,
> > 
> > If I understand you correctly, you simply want to add more queries to the  
> > existing range query? You can combine queries together using a boolean  
> > query: [http://www](http://www).\*\*[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/) **reference/query-dsl/bool-**  
> > query.html[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> > 
> > The range query would be one clause and your text search would be another  
> > clause that are "joined" together using a boolean query.
> > 
> > If you choose to use a filter instead, there is a boolean filter.
> > 
> > Cheers,
> > 
> > Ivan
> > 
> > On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > 
> > > Hello All,
> > > 
> > > I am trying to create a query to filter based on the date range  
> > > provided, search for specific ID and also with some "search text or some  
> > > search keywords"
> > > 
> > > I am able to fetch the records with the date range and ID provided, but  
> > > unable to search for any text within these records:
> > > 
> > > curl -XGET '[http://local:9200/Index/Type/\*\*\_search?pretty=true](http://local:9200/Index/Type/**_search?pretty=true)[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)'  
> > > -d '{ "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to"  
> > > : "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > > {"Timestamp":{"order":"desc"}}\*\*}'
> > > 
> > > The above query is working fine , but how do I add TEXT search to the  
> > > above query so that I can query based on smoe sample keywords and date  
> > > range and look for specific ID .
> > > 
> > > For example if I wanted to search for "Elastic" , "MyName" and  
> > > "Someother keyword"(wanted to perform single and mulitple keyword search)  
> > > in the "\_source" field with in the documents.
> > > 
> > > Many Thanks in Advance 🙂
> > > 
> > > Regards,  
> > > Shannu.
> > > 
> > > --
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 9, 2012, 8:50am UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/5 "2012-10-09T08:50:44Z")

</div>

Thats great.

Thanks a lot Ivan, really appreciate ur help.

Cheers,  
Shannu.

On Monday, October 8, 2012 9:50:05 PM UTC+1, Ivan Brusic wrote:

> The page I linked to already has an example. Here is another example with  
> your query, except with an added boolean query with a trivial text query.
> 
> {  
> "query": {  
> "bool": {  
> "must": {  
> "range": {  
> "Date": {  
> "from": "2012-10-03T09:00:00",  
> "to": "2012-10-03T14:00:00"  
> }  
> }  
> },  
> "must": {  
> "text": {  
> "\_all": "elastic"  
> }  
> }  
> }  
> },  
> "filter": {  
> "term": {  
> "ID": "123"  
> }  
> },  
> "sort": {  
> "Timestamp": {  
> "order": "desc"  
> }  
> }  
> }
> 
> On Mon, Oct 8, 2012 at 9:23 AM, shannu \<[shanmukh...@gmail.com](mailto:shanmukh...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hey Ivan ,
> > 
> > thanks a lot for the reply.
> > 
> > I am a newbie and struggling to work out this bit.
> > 
> > Do u mind sending me a sample query for single & multiple text search and  
> > boolean query to combine range query and the text please.
> > 
> > That will be very helpful.
> > 
> > Regards,  
> > Shannu.
> > 
> > On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:
> > 
> > > Hi Shannu,
> > > 
> > > If I understand you correctly, you simply want to add more queries to  
> > > the existing range query? You can combine queries together using a boolean  
> > > query: [http://www](http://www).\*\*[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/*)_reference/query-dsl/bool-_  
> > > \*query.html[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> > > 
> > > The range query would be one clause and your text search would be  
> > > another clause that are "joined" together using a boolean query.
> > > 
> > > If you choose to use a filter instead, there is a boolean filter.
> > > 
> > > Cheers,
> > > 
> > > Ivan
> > > 
> > > On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > > 
> > > > Hello All,
> > > > 
> > > > I am trying to create a query to filter based on the date range  
> > > > provided, search for specific ID and also with some "search text or some  
> > > > search keywords"
> > > > 
> > > > I am able to fetch the records with the date range and ID provided, but  
> > > > unable to search for any text within these records:
> > > > 
> > > > curl -XGET '[http://local:9200/Index/Type/\*\*\_search?pretty=true](http://local:9200/Index/Type/**_search?pretty=true)[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)'  
> > > > -d '{ "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to"  
> > > > : "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > > > {"Timestamp":{"order":"desc"}}\*\*}'
> > > > 
> > > > The above query is working fine , but how do I add TEXT search to the  
> > > > above query so that I can query based on smoe sample keywords and date  
> > > > range and look for specific ID .
> > > > 
> > > > For example if I wanted to search for "Elastic" , "MyName" and  
> > > > "Someother keyword"(wanted to perform single and mulitple keyword search)  
> > > > in the "\_source" field with in the documents.
> > > > 
> > > > Many Thanks in Advance 🙂
> > > > 
> > > > Regards,  
> > > > Shannu.
> > > > 
> > > > --
> > > 
> > > --

--

---

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 9, 2012, 10:15am UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/6 "2012-10-09T10:15:51Z")

</div>

Hey Ivan ,

sorry to bother u again.

I am able to perform single keyword search, but unable to achieve the  
multiple keyword search:

Single Keyword Search(works fine):  
curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query" :  
{"text":{"\_all":"Shannu"}}}'

or

curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query" :  
{"match":{"\_all":"Shannu"}}}'

the above query bring back the correct results

Mutiple Keyword Search:

curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query" :  
{"match":{"\_all":["Shannu","Ivan","Something"]}}}' - this query executes  
with out error but not the expected results

Result: {  
"took" : 6,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" :   
}  
}

but I am expecting the items or docs which has those keywords I  
mentioned..Am I missing something here in the query ?

or is there other way for multiple text search ???

Many thnx in Advance 🙂

Cheers,  
Shannu.

On Monday, October 8, 2012 9:50:05 PM UTC+1, Ivan Brusic wrote:

> The page I linked to already has an example. Here is another example with  
> your query, except with an added boolean query with a trivial text query.
> 
> {  
> "query": {  
> "bool": {  
> "must": {  
> "range": {  
> "Date": {  
> "from": "2012-10-03T09:00:00",  
> "to": "2012-10-03T14:00:00"  
> }  
> }  
> },  
> "must": {  
> "text": {  
> "\_all": "elastic"  
> }  
> }  
> }  
> },  
> "filter": {  
> "term": {  
> "ID": "123"  
> }  
> },  
> "sort": {  
> "Timestamp": {  
> "order": "desc"  
> }  
> }  
> }
> 
> On Mon, Oct 8, 2012 at 9:23 AM, shannu \<[shanmukh...@gmail.com](mailto:shanmukh...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hey Ivan ,
> > 
> > thanks a lot for the reply.
> > 
> > I am a newbie and struggling to work out this bit.
> > 
> > Do u mind sending me a sample query for single & multiple text search and  
> > boolean query to combine range query and the text please.
> > 
> > That will be very helpful.
> > 
> > Regards,  
> > Shannu.
> > 
> > On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:
> > 
> > > Hi Shannu,
> > > 
> > > If I understand you correctly, you simply want to add more queries to  
> > > the existing range query? You can combine queries together using a boolean  
> > > query: [http://www](http://www).\*\*[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/*)_reference/query-dsl/bool-_  
> > > \*query.html[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> > > 
> > > The range query would be one clause and your text search would be  
> > > another clause that are "joined" together using a boolean query.
> > > 
> > > If you choose to use a filter instead, there is a boolean filter.
> > > 
> > > Cheers,
> > > 
> > > Ivan
> > > 
> > > On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > > 
> > > > Hello All,
> > > > 
> > > > I am trying to create a query to filter based on the date range  
> > > > provided, search for specific ID and also with some "search text or some  
> > > > search keywords"
> > > > 
> > > > I am able to fetch the records with the date range and ID provided, but  
> > > > unable to search for any text within these records:
> > > > 
> > > > curl -XGET '[http://local:9200/Index/Type/\*\*\_search?pretty=true](http://local:9200/Index/Type/**_search?pretty=true)[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)'  
> > > > -d '{ "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to"  
> > > > : "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > > > {"Timestamp":{"order":"desc"}}\*\*}'
> > > > 
> > > > The above query is working fine , but how do I add TEXT search to the  
> > > > above query so that I can query based on smoe sample keywords and date  
> > > > range and look for specific ID .
> > > > 
> > > > For example if I wanted to search for "Elastic" , "MyName" and  
> > > > "Someother keyword"(wanted to perform single and mulitple keyword search)  
> > > > in the "\_source" field with in the documents.
> > > > 
> > > > Many Thanks in Advance 🙂
> > > > 
> > > > Regards,  
> > > > Shannu.
> > > > 
> > > > --
> > > 
> > > --

--

---

<div class="post-metadata">

**Author:** ![Amjad\_Farooq](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Amjad\_Farooq](https://discuss.elastic.co/u/Amjad_Farooq)\
**Post date:** [October 11, 2012, 4:21pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/7 "2012-10-11T16:21:12Z")

</div>

I am facing same issue any help would be appreciated

thanks

On Tuesday, October 9, 2012 3:15:51 PM UTC+5, shannu wrote:

> Hey Ivan ,
> 
> sorry to bother u again.
> 
> I am able to perform single keyword search, but unable to achieve the  
> multiple keyword search:
> 
> Single Keyword Search(works fine):  
> curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query"  
> : {"text":{"\_all":"Shannu"}}}'
> 
> or
> 
> curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query"  
> : {"match":{"\_all":"Shannu"}}}'
> 
> the above query bring back the correct results
> 
> Mutiple Keyword Search:
> 
> curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query"  
> : {"match":{"\_all":["Shannu","Ivan","Something"]}}}' - this query executes  
> with out error but not the expected results
> 
> Result: {  
> "took" : 6,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> but I am expecting the items or docs which has those keywords I  
> mentioned..Am I missing something here in the query ?
> 
> or is there other way for multiple text search ???
> 
> Many thnx in Advance 🙂
> 
> Cheers,  
> Shannu.
> 
> On Monday, October 8, 2012 9:50:05 PM UTC+1, Ivan Brusic wrote:
> 
> > The page I linked to already has an example. Here is another example with  
> > your query, except with an added boolean query with a trivial text query.
> > 
> > {  
> > "query": {  
> > "bool": {  
> > "must": {  
> > "range": {  
> > "Date": {  
> > "from": "2012-10-03T09:00:00",  
> > "to": "2012-10-03T14:00:00"  
> > }  
> > }  
> > },  
> > "must": {  
> > "text": {  
> > "\_all": "elastic"  
> > }  
> > }  
> > }  
> > },  
> > "filter": {  
> > "term": {  
> > "ID": "123"  
> > }  
> > },  
> > "sort": {  
> > "Timestamp": {  
> > "order": "desc"  
> > }  
> > }  
> > }
> > 
> > On Mon, Oct 8, 2012 at 9:23 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > 
> > > Hey Ivan ,
> > > 
> > > thanks a lot for the reply.
> > > 
> > > I am a newbie and struggling to work out this bit.
> > > 
> > > Do u mind sending me a sample query for single & multiple text search  
> > > and boolean query to combine range query and the text please.
> > > 
> > > That will be very helpful.
> > > 
> > > Regards,  
> > > Shannu.
> > > 
> > > On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:
> > > 
> > > > Hi Shannu,
> > > > 
> > > > If I understand you correctly, you simply want to add more queries to  
> > > > the existing range query? You can combine queries together using a boolean  
> > > > query: [http://www](http://www).\*\*[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/**reference/query-dsl/bool-)  
> > > > \*\*query.html[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> > > > 
> > > > The range query would be one clause and your text search would be  
> > > > another clause that are "joined" together using a boolean query.
> > > > 
> > > > If you choose to use a filter instead, there is a boolean filter.
> > > > 
> > > > Cheers,
> > > > 
> > > > Ivan
> > > > 
> > > > On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > > > 
> > > > > Hello All,
> > > > > 
> > > > > I am trying to create a query to filter based on the date range  
> > > > > provided, search for specific ID and also with some "search text or some  
> > > > > search keywords"
> > > > > 
> > > > > I am able to fetch the records with the date range and ID provided,  
> > > > > but unable to search for any text within these records:
> > > > > 
> > > > > curl -XGET '[http://local:9200/Index/Type/\*\*\_search?pretty=true](http://local:9200/Index/Type/**_search?pretty=true)[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)'  
> > > > > -d '{ "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to"  
> > > > > : "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > > > > {"Timestamp":{"order":"desc"}}\*\*}'
> > > > > 
> > > > > The above query is working fine , but how do I add TEXT search to the  
> > > > > above query so that I can query based on smoe sample keywords and date  
> > > > > range and look for specific ID .
> > > > > 
> > > > > For example if I wanted to search for "Elastic" , "MyName" and  
> > > > > "Someother keyword"(wanted to perform single and mulitple keyword search)  
> > > > > in the "\_source" field with in the documents.
> > > > > 
> > > > > Many Thanks in Advance 🙂
> > > > > 
> > > > > Regards,  
> > > > > Shannu.
> > > > > 
> > > > > --
> > > > 
> > > > --

--

---

<div class="post-metadata">

**Author:** ![Amjad\_Farooq](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Amjad\_Farooq](https://discuss.elastic.co/u/Amjad_Farooq)\
**Post date:** [October 11, 2012, 5:26pm UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/8 "2012-10-11T17:26:43Z")

</div>

Hi check this Hope it will help you

$query = new Elastica\_Query\_Builder('{  
"query": {  
"bool": {  
"must": {  
"query\_string": {  
"query":"chicken",  
"default\_field": "\_all"  
}  
},  
"must\_not": {  
"query\_string": {  
"query":"Potatoes",  
"default\_field": "\_all"  
}  
}  
}  
},  
"facets": {  
"active": {  
"terms": {  
"field": "active"  
}  
}  
},  
"sort":{  
"id": {  
"order": "desc"  
}  
},  
"from": "0",  
"size": "25"  
}');

```
    // Create a raw query since the query above can't be passed 

```

directly to the search method used below  
$query = new Elastica\_Query($query-\>toArray());

```
    // Create the search object and inject the client
    $search = new Elastica_Search(new Elastica_Client());
     
    // Configure and execute the search
    $resultSet = $search->addIndex('foods')
                        ->addType('food')
                        ->search($query);

        debug($resultSet);

```

On Tuesday, October 9, 2012 3:15:51 PM UTC+5, shannu wrote:

> Hey Ivan ,
> 
> sorry to bother u again.
> 
> I am able to perform single keyword search, but unable to achieve the  
> multiple keyword search:
> 
> Single Keyword Search(works fine):  
> curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query"  
> : {"text":{"\_all":"Shannu"}}}'
> 
> or
> 
> curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query"  
> : {"match":{"\_all":"Shannu"}}}'
> 
> the above query bring back the correct results
> 
> Mutiple Keyword Search:
> 
> curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d '{"query"  
> : {"match":{"\_all":["Shannu","Ivan","Something"]}}}' - this query executes  
> with out error but not the expected results
> 
> Result: {  
> "took" : 6,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> but I am expecting the items or docs which has those keywords I  
> mentioned..Am I missing something here in the query ?
> 
> or is there other way for multiple text search ???
> 
> Many thnx in Advance 🙂
> 
> Cheers,  
> Shannu.
> 
> On Monday, October 8, 2012 9:50:05 PM UTC+1, Ivan Brusic wrote:
> 
> > The page I linked to already has an example. Here is another example with  
> > your query, except with an added boolean query with a trivial text query.
> > 
> > {  
> > "query": {  
> > "bool": {  
> > "must": {  
> > "range": {  
> > "Date": {  
> > "from": "2012-10-03T09:00:00",  
> > "to": "2012-10-03T14:00:00"  
> > }  
> > }  
> > },  
> > "must": {  
> > "text": {  
> > "\_all": "elastic"  
> > }  
> > }  
> > }  
> > },  
> > "filter": {  
> > "term": {  
> > "ID": "123"  
> > }  
> > },  
> > "sort": {  
> > "Timestamp": {  
> > "order": "desc"  
> > }  
> > }  
> > }
> > 
> > On Mon, Oct 8, 2012 at 9:23 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > 
> > > Hey Ivan ,
> > > 
> > > thanks a lot for the reply.
> > > 
> > > I am a newbie and struggling to work out this bit.
> > > 
> > > Do u mind sending me a sample query for single & multiple text search  
> > > and boolean query to combine range query and the text please.
> > > 
> > > That will be very helpful.
> > > 
> > > Regards,  
> > > Shannu.
> > > 
> > > On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:
> > > 
> > > > Hi Shannu,
> > > > 
> > > > If I understand you correctly, you simply want to add more queries to  
> > > > the existing range query? You can combine queries together using a boolean  
> > > > query: [http://www](http://www).\*\*[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/**reference/query-dsl/bool-)  
> > > > \*\*query.html[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> > > > 
> > > > The range query would be one clause and your text search would be  
> > > > another clause that are "joined" together using a boolean query.
> > > > 
> > > > If you choose to use a filter instead, there is a boolean filter.
> > > > 
> > > > Cheers,
> > > > 
> > > > Ivan
> > > > 
> > > > On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > > > 
> > > > > Hello All,
> > > > > 
> > > > > I am trying to create a query to filter based on the date range  
> > > > > provided, search for specific ID and also with some "search text or some  
> > > > > search keywords"
> > > > > 
> > > > > I am able to fetch the records with the date range and ID provided,  
> > > > > but unable to search for any text within these records:
> > > > > 
> > > > > curl -XGET '[http://local:9200/Index/Type/\*\*\_search?pretty=true](http://local:9200/Index/Type/**_search?pretty=true)[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)'  
> > > > > -d '{ "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to"  
> > > > > : "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > > > > {"Timestamp":{"order":"desc"}}\*\*}'
> > > > > 
> > > > > The above query is working fine , but how do I add TEXT search to the  
> > > > > above query so that I can query based on smoe sample keywords and date  
> > > > > range and look for specific ID .
> > > > > 
> > > > > For example if I wanted to search for "Elastic" , "MyName" and  
> > > > > "Someother keyword"(wanted to perform single and mulitple keyword search)  
> > > > > in the "\_source" field with in the documents.
> > > > > 
> > > > > Many Thanks in Advance 🙂
> > > > > 
> > > > > Regards,  
> > > > > Shannu.
> > > > > 
> > > > > --
> > > > 
> > > > --

--

---

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 12, 2012, 10:03am UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/9 "2012-10-12T10:03:54Z")

</div>

Thanks a lot Amjad.

On Thursday, October 11, 2012 6:26:43 PM UTC+1, amjad wrote:

> Hi check this Hope it will help you
> 
> $query = new Elastica\_Query\_Builder('{  
> "query": {  
> "bool": {  
> "must": {  
> "query\_string": {  
> "query":"chicken",  
> "default\_field": "\_all"  
> }  
> },  
> "must\_not": {  
> "query\_string": {  
> "query":"Potatoes",  
> "default\_field": "\_all"  
> }  
> }  
> }  
> },  
> "facets": {  
> "active": {  
> "terms": {  
> "field": "active"  
> }  
> }  
> },  
> "sort":{  
> "id": {  
> "order": "desc"  
> }  
> },  
> "from": "0",  
> "size": "25"  
> }');
> 
> ```
> // Create a raw query since the query above can't be passed 
> 
> ```
> 
> directly to the search method used below  
> $query = new Elastica\_Query($query-\>toArray());
> 
> ```
> // Create the search object and inject the client
> $search = new Elastica_Search(new Elastica_Client());
>      
> // Configure and execute the search
> $resultSet = $search->addIndex('foods')
> ->addType('food')
> ->search($query);
> 
> debug($resultSet);
> 
> ```
> 
> On Tuesday, October 9, 2012 3:15:51 PM UTC+5, shannu wrote:
> 
> > Hey Ivan ,
> > 
> > sorry to bother u again.
> > 
> > I am able to perform single keyword search, but unable to achieve the  
> > multiple keyword search:
> > 
> > Single Keyword Search(works fine):  
> > curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d  
> > '{"query" : {"text":{"\_all":"Shannu"}}}'
> > 
> > or
> > 
> > curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d  
> > '{"query" : {"match":{"\_all":"Shannu"}}}'
> > 
> > the above query bring back the correct results
> > 
> > Mutiple Keyword Search:
> > 
> > curl -XGET '[http://localhost/index/type/\_search?pretty=true](http://localhost/index/type/_search?pretty=true)' -d  
> > '{"query" : {"match":{"\_all":["Shannu","Ivan","Something"]}}}' - this query  
> > executes with out error but not the expected results
> > 
> > Result: {  
> > "took" : 6,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 0,  
> > "max\_score" : null,  
> > "hits" :   
> > }  
> > }
> > 
> > but I am expecting the items or docs which has those keywords I  
> > mentioned..Am I missing something here in the query ?
> > 
> > or is there other way for multiple text search ???
> > 
> > Many thnx in Advance 🙂
> > 
> > Cheers,  
> > Shannu.
> > 
> > On Monday, October 8, 2012 9:50:05 PM UTC+1, Ivan Brusic wrote:
> > 
> > > The page I linked to already has an example. Here is another example  
> > > with your query, except with an added boolean query with a trivial text  
> > > query.
> > > 
> > > {  
> > > "query": {  
> > > "bool": {  
> > > "must": {  
> > > "range": {  
> > > "Date": {  
> > > "from": "2012-10-03T09:00:00",  
> > > "to": "2012-10-03T14:00:00"  
> > > }  
> > > }  
> > > },  
> > > "must": {  
> > > "text": {  
> > > "\_all": "elastic"  
> > > }  
> > > }  
> > > }  
> > > },  
> > > "filter": {  
> > > "term": {  
> > > "ID": "123"  
> > > }  
> > > },  
> > > "sort": {  
> > > "Timestamp": {  
> > > "order": "desc"  
> > > }  
> > > }  
> > > }
> > > 
> > > On Mon, Oct 8, 2012 at 9:23 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > > 
> > > > Hey Ivan ,
> > > > 
> > > > thanks a lot for the reply.
> > > > 
> > > > I am a newbie and struggling to work out this bit.
> > > > 
> > > > Do u mind sending me a sample query for single & multiple text search  
> > > > and boolean query to combine range query and the text please.
> > > > 
> > > > That will be very helpful.
> > > > 
> > > > Regards,  
> > > > Shannu.
> > > > 
> > > > On Monday, October 8, 2012 5:05:49 PM UTC+1, Ivan Brusic wrote:
> > > > 
> > > > > Hi Shannu,
> > > > > 
> > > > > If I understand you correctly, you simply want to add more queries to  
> > > > > the existing range query? You can combine queries together using a boolean  
> > > > > query: [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > > > > reference/query-dsl/bool-\*\*query.html[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)
> > > > > 
> > > > > The range query would be one clause and your text search would be  
> > > > > another clause that are "joined" together using a boolean query.
> > > > > 
> > > > > If you choose to use a filter instead, there is a boolean filter.
> > > > > 
> > > > > Cheers,
> > > > > 
> > > > > Ivan
> > > > > 
> > > > > On Mon, Oct 8, 2012 at 8:55 AM, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) wrote:
> > > > > 
> > > > > > Hello All,
> > > > > > 
> > > > > > I am trying to create a query to filter based on the date range  
> > > > > > provided, search for specific ID and also with some "search text or some  
> > > > > > search keywords"
> > > > > > 
> > > > > > I am able to fetch the records with the date range and ID provided,  
> > > > > > but unable to search for any text within these records:
> > > > > > 
> > > > > > curl -XGET '[http://local:9200/Index/Type/\*\*\_search?pretty=true](http://local:9200/Index/Type/**_search?pretty=true)[http://local:9200/Index/Type/\_search?pretty=true](http://local:9200/Index/Type/_search?pretty=true)'  
> > > > > > -d '{ "query" : {"range" : {"Date" : { "from" : "2012-10-03T09:00:00", "to"  
> > > > > > : "2012-10-03T14:00:00" }}},"filter" : {"term" : { "ID" : "123" }}, "sort":  
> > > > > > {"Timestamp":{"order":"desc"}}\*\*}'
> > > > > > 
> > > > > > The above query is working fine , but how do I add TEXT search to the  
> > > > > > above query so that I can query based on smoe sample keywords and date  
> > > > > > range and look for specific ID .
> > > > > > 
> > > > > > For example if I wanted to search for "Elastic" , "MyName" and  
> > > > > > "Someother keyword"(wanted to perform single and mulitple keyword search)  
> > > > > > in the "\_source" field with in the documents.
> > > > > > 
> > > > > > Many Thanks in Advance 🙂
> > > > > > 
> > > > > > Regards,  
> > > > > > Shannu.
> > > > > > 
> > > > > > --
> > > > > 
> > > > > --

--

---

<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, 3:09am UTC](https://discuss.elastic.co/t/unable-to-search-for-text/9275/10 "2017-07-06T03:09:05Z")

</div>


