# Different search results from ES webservice and python's API pyres

**URL:** <https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715>\
**Category:** Elasticsearch\
**Created:** [August 11, 2012, 12:04am UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715 "2012-08-11T00:04:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@Abhishek\_Pratap](https://discuss.elastic.co/u/Abhishek_Pratap)\
**Post date:** [August 11, 2012, 12:04am UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/1 "2012-08-11T00:04:03Z")

</div>

Hi Guys

I am sort of confused why I am getting two different search results when I  
query against same index using webservice and ES python's API pyres.

from webservice  
curl -XGET localhost  
:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus[http://128.55.54.143:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus](http://128.55.54.143:9201/ncbi_taxa_names/taxa_names/_search?q=tax_name:Myxococcus)  
{"took":5,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":15,"  
}}}} # only copying the #hits

from pyres:  
conn.open\_index("ncbi\_taxa\_names")  
q = TermQuery("tax\_name","Myxococcus")  
results = conn.search(query=q)  
for r in results:  
print r  
.....:  
no hits :

Am I missing something ?

Thanks!  
-Abhi

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 11, 2012, 12:19am UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/2 "2012-08-11T00:19:07Z")

</div>

ES uses a QueryString (analyzed) but you create with Pyes a TermQuery ( not analyzed ).  
Try this or use a TextQuery  
TermQuery("tax\_name","myxococcus")

## David

Le 11 août 2012 à 02:04, Abhishek Pratap [abhishek.vit@gmail.com](mailto:abhishek.vit@gmail.com) a écrit :

> Hi Guys
> 
> I am sort of confused why I am getting two different search results when I query against same index using webservice and ES python's API pyres.
> 
> from webservice  
> curl -XGET localhost:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus  
> {"took":5,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":15," }}}} # only copying the #hits
> 
> from pyres:  
> conn.open\_index("ncbi\_taxa\_names")  
> q = TermQuery("tax\_name","Myxococcus")  
> results = conn.search(query=q)  
> for r in results:  
> print r  
> .....:  
> no hits :
> 
> Am I missing something ?
> 
> ## Thanks! -Abhi

--

---

<div class="post-metadata">

**Author:** ![Abhishek\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@Abhishek\_Pratap](https://discuss.elastic.co/u/Abhishek_Pratap)\
**Post date:** [August 13, 2012, 7:38pm UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/3 "2012-08-13T19:38:45Z")

</div>

Hi David

Thanks for your reply. Could you please elaborate a little bit more on what  
you meant by analyzed string in the context of ES. I am new to ES and not  
quite sure if I understand it fully.

Thanks!  
-Abhi

On Friday, August 10, 2012 5:19:07 PM UTC-7, David Pilato wrote:

> ES uses a QueryString (analyzed) but you create with Pyes a TermQuery (  
> not analyzed ).  
> Try this or use a TextQuery  
> TermQuery("tax\_name","myxococcus")
> 
> ## David
> 
> Le 11 août 2012 à 02:04, Abhishek Pratap \<[abhish...@gmail.com](mailto:abhish...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> Hi Guys
> 
> I am sort of confused why I am getting two different search results when I  
> query against same index using webservice and ES python's API pyres.
> 
> from webservice  
> curl -XGET localhost  
> :9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus[http://128.55.54.143:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus](http://128.55.54.143:9201/ncbi_taxa_names/taxa_names/_search?q=tax_name:Myxococcus)  
> {"took":5,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":15,"  
> }}}} # only copying the #hits
> 
> from pyres:  
> conn.open\_index("ncbi\_taxa\_names")  
> q = TermQuery("tax\_name","Myxococcus")  
> results = conn.search(query=q)  
> for r in results:  
> print r  
> .....:  
> no hits :
> 
> Am I missing something ?
> 
> Thanks!  
> -Abhi
> 
> --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 13, 2012, 8:32pm UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/4 "2012-08-13T20:32:47Z")

</div>

Analyze means to transform any text into tokens which will be indexed depending on your analysis rules.

Default ES analyzer will remove common english words (I, am, you, are, this...). It will also lowercase everything.

Then when searching, your text will be compared to indexed text.

So, you have in index : myxococcus .  
If you search for Myxococcus without analyze, you won't find anything. If you analyze your search, Myxococcus will be transformed into myxococcus and it will match your doument.

## hope this helps David

Le 13 août 2012 à 21:38, Abhishek Pratap [abhishek.vit@gmail.com](mailto:abhishek.vit@gmail.com) a écrit :

> Hi David
> 
> Thanks for your reply. Could you please elaborate a little bit more on what you meant by analyzed string in the context of ES. I am new to ES and not quite sure if I understand it fully.
> 
> Thanks!  
> -Abhi
> 
> On Friday, August 10, 2012 5:19:07 PM UTC-7, David Pilato wrote:  
> ES uses a QueryString (analyzed) but you create with Pyes a TermQuery ( not analyzed ).  
> Try this or use a TextQuery  
> TermQuery("tax\_name","myxococcus")
> 
> ## David
> 
> Le 11 août 2012 à 02:04, Abhishek Pratap [abhish...@gmail.com](mailto:abhish...@gmail.com) a écrit :
> 
> > Hi Guys
> > 
> > I am sort of confused why I am getting two different search results when I query against same index using webservice and ES python's API pyres.
> > 
> > from webservice  
> > curl -XGET localhost:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus  
> > {"took":5,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":15," }}}} # only copying the #hits
> > 
> > from pyres:  
> > conn.open\_index("ncbi\_taxa\_names")  
> > q = TermQuery("tax\_name","Myxococcus")  
> > results = conn.search(query=q)  
> > for r in results:  
> > print r  
> > .....:  
> > no hits :
> > 
> > Am I missing something ?
> > 
> > ## Thanks! -Abhi
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Abhishek\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@Abhishek\_Pratap](https://discuss.elastic.co/u/Abhishek_Pratap)\
**Post date:** [August 13, 2012, 9:44pm UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/5 "2012-08-13T21:44:03Z")

</div>

Thanks David. One more thing

Any doc on what ways I can query ES using pyes. The doc  
on [Queries — PyES Documentation v0.17.0 (unstable) documentation](http://packages.python.org/pyes/manual/queries.html#quering) has some  
info but I dont see examples which I fund more useful.

For example how can I create an analyzed query string in pyes for search.

Thanks!  
-Abhi

On Monday, August 13, 2012 1:32:47 PM UTC-7, David Pilato wrote:

> Analyze means to transform any text into tokens which will be indexed  
> depending on your analysis rules.
> 
> Default ES analyzer will remove common english words (I, am, you, are,  
> this...). It will also lowercase everything.
> 
> Then when searching, your text will be compared to indexed text.
> 
> So, you have in index : myxococcus .  
> If you search for Myxococcus without analyze, you won't find anything. If  
> you analyze your search, Myxococcus will be transformed into myxococcus  
> and it will match your doument.
> 
> ## hope this helps David
> 
> Le 13 août 2012 à 21:38, Abhishek Pratap \<[abhish...@gmail.com](mailto:abhish...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> Hi David
> 
> Thanks for your reply. Could you please elaborate a little bit more on  
> what you meant by analyzed string in the context of ES. I am new to ES and  
> not quite sure if I understand it fully.
> 
> Thanks!  
> -Abhi
> 
> On Friday, August 10, 2012 5:19:07 PM UTC-7, David Pilato wrote:
> 
> > ES uses a QueryString (analyzed) but you create with Pyes a TermQuery (  
> > not analyzed ).  
> > Try this or use a TextQuery  
> > TermQuery("tax\_name","myxococcus")
> > 
> > ## David
> > 
> > Le 11 août 2012 à 02:04, Abhishek Pratap [abhish...@gmail.com](mailto:abhish...@gmail.com) a écrit :
> > 
> > Hi Guys
> > 
> > I am sort of confused why I am getting two different search results when  
> > I query against same index using webservice and ES python's API pyres.
> > 
> > from webservice  
> > curl -XGET localhost  
> > :9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus[http://128.55.54.143:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus](http://128.55.54.143:9201/ncbi_taxa_names/taxa_names/_search?q=tax_name:Myxococcus)  
> > {"took":5,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":15,"  
> > }}}} # only copying the #hits
> > 
> > from pyres:  
> > conn.open\_index("ncbi\_taxa\_names")  
> > q = TermQuery("tax\_name","Myxococcus")  
> > results = conn.search(query=q)  
> > for r in results:  
> > print r  
> > .....:  
> > no hits :
> > 
> > Am I missing something ?
> > 
> > Thanks!  
> > -Abhi
> > 
> > --
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 13, 2012, 9:58pm UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/6 "2012-08-13T21:58:50Z")

</div>

Sorry. I don't know pyes.  
Anyone? Pyes gurus?

--  
David

Le 13 août 2012 à 23:44, Abhishek Pratap [abhishek.vit@gmail.com](mailto:abhishek.vit@gmail.com) a écrit :

> Thanks David. One more thing
> 
> Any doc on what ways I can query ES using pyes. The doc on [Queries — PyES Documentation v0.17.0 (unstable) documentation](http://packages.python.org/pyes/manual/queries.html#quering) has some info but I dont see examples which I fund more useful.
> 
> For example how can I create an analyzed query string in pyes for search.
> 
> Thanks!  
> -Abhi
> 
> On Monday, August 13, 2012 1:32:47 PM UTC-7, David Pilato wrote:  
> Analyze means to transform any text into tokens which will be indexed depending on your analysis rules.
> 
> Default ES analyzer will remove common english words (I, am, you, are, this...). It will also lowercase everything.
> 
> Then when searching, your text will be compared to indexed text.
> 
> So, you have in index : myxococcus .  
> If you search for Myxococcus without analyze, you won't find anything. If you analyze your search, Myxococcus will be transformed into myxococcus and it will match your doument.
> 
> ## hope this helps David
> 
> Le 13 août 2012 à 21:38, Abhishek Pratap [abhish...@gmail.com](mailto:abhish...@gmail.com) a écrit :
> 
> > Hi David
> > 
> > Thanks for your reply. Could you please elaborate a little bit more on what you meant by analyzed string in the context of ES. I am new to ES and not quite sure if I understand it fully.
> > 
> > Thanks!  
> > -Abhi
> > 
> > On Friday, August 10, 2012 5:19:07 PM UTC-7, David Pilato wrote:  
> > ES uses a QueryString (analyzed) but you create with Pyes a TermQuery ( not analyzed ).  
> > Try this or use a TextQuery  
> > TermQuery("tax\_name","myxococcus")
> > 
> > ## David
> > 
> > Le 11 août 2012 à 02:04, Abhishek Pratap [abhish...@gmail.com](mailto:abhish...@gmail.com) a écrit :
> > 
> > > Hi Guys
> > > 
> > > I am sort of confused why I am getting two different search results when I query against same index using webservice and ES python's API pyres.
> > > 
> > > from webservice  
> > > curl -XGET localhost:9201/ncbi\_taxa\_names/taxa\_names/\_search?q=tax\_name:Myxococcus  
> > > {"took":5,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":15," }}}} # only copying the #hits
> > > 
> > > from pyres:  
> > > conn.open\_index("ncbi\_taxa\_names")  
> > > q = TermQuery("tax\_name","Myxococcus")  
> > > results = conn.search(query=q)  
> > > for r in results:  
> > > print r  
> > > .....:  
> > > no hits :
> > > 
> > > Am I missing something ?
> > > 
> > > ## Thanks! -Abhi
> > 
> > --
> 
> --

--

---

<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:16am UTC](https://discuss.elastic.co/t/different-search-results-from-es-webservice-and-pythons-api-pyres/8715/7 "2017-07-06T03:16:30Z")

</div>


