# Missing terms API

**URL:** <https://discuss.elastic.co/t/missing-terms-api/3191>\
**Category:** Elasticsearch\
**Created:** [August 6, 2010, 12:54pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191 "2010-08-06T12:54:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [August 6, 2010, 12:54pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191/1 "2010-08-06T12:54:16Z")

</div>

Hi,  
I have a requirement to display all (distinct) terms from one or more  
fields, alphabetically sorted with pagination (because all terms need to  
be displayed, not only most popular ones) for something like simple auto  
suggest/dictionary.

I've checked API (before) and I think Terms API was ideal for this. Now,  
with Terms API removed I don't know if or how can I achieve some  
functionality (especially 'prefix', 'pagination' and 'sort = term') with  
facets.

I understand executing a faceted search with 0 result size, like here:

curl -XGET '[http://localhost:9200/index/test/\_search](http://localhost:9200/index/test/_search)' -d '  
{  
"size" : 0,  
"query" : {  
"match\_all" : { }  
},  
"facets" : {  
"tag" : {  
"terms" : {  
"field" : "text",  
"size" : 10000  
}  
}  
}  
}  
'

will give me terms from field 'text', but how can I get all terms (not  
only "size"), alphabetically sorted and with pagination (without Terms  
API)?

Thanks,  
Tomislav

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 6, 2010, 4:00pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191/2 "2010-08-06T16:00:39Z")

</div>

I've seen this asked a few times on the list and almost asked it once  
myself 🙂

Replaced by the facets api. Specifically, term facets will give you  
what you need.

On Aug 6, 6:54 am, Tomislav Poljak [tpol...@gmail.com](mailto:tpol...@gmail.com) wrote:

> Hi,  
> I have a requirement to display all (distinct) terms from one or more  
> fields, alphabetically sorted with pagination (because all terms need to  
> be displayed, not only most popular ones) for something like simple auto  
> suggest/dictionary.
> 
> I've checked API (before) and I think Terms API was ideal for this. Now,  
> with Terms API removed I don't know if or how can I achieve some  
> functionality (especially 'prefix', 'pagination' and 'sort = term') with  
> facets.
> 
> I understand executing a faceted search with 0 result size, like here:
> 
> curl -XGET '[http://localhost:9200/index/test/\_search'-d](http://localhost:9200/index/test/_search'-d) '  
> {  
> "size" : 0,  
> "query" : {  
> "match\_all" : { }  
> },  
> "facets" : {  
> "tag" : {  
> "terms" : {  
> "field" : "text",  
> "size" : 10000  
> }  
> }  
> } }
> 
> '
> 
> will give me terms from field 'text', but how can I get all terms (not  
> only "size"), alphabetically sorted and with pagination (without Terms  
> API)?
> 
> Thanks,  
> Tomislav

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 6, 2010, 4:02pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191/3 "2010-08-06T16:02:16Z")

</div>

Sorry, didn't read whole question, disregard!!!

On Aug 6, 10:00 am, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:

> I've seen this asked a few times on the list and almost asked it once  
> myself 🙂
> 
> Replaced by the facets api. Specifically, term facets will give you  
> what you need.
> 
> On Aug 6, 6:54 am, Tomislav Poljak [tpol...@gmail.com](mailto:tpol...@gmail.com) wrote:
> 
> > Hi,  
> > I have a requirement to display all (distinct) terms from one or more  
> > fields, alphabetically sorted with pagination (because all terms need to  
> > be displayed, not only most popular ones) for something like simple auto  
> > suggest/dictionary.
> 
> > I've checked API (before) and I think Terms API was ideal for this. Now,  
> > with Terms API removed I don't know if or how can I achieve some  
> > functionality (especially 'prefix', 'pagination' and 'sort = term') with  
> > facets.
> 
> > I understand executing a faceted search with 0 result size, like here:
> 
> > curl -XGET '[http://localhost:9200/index/test/\_search'-d'](http://localhost:9200/index/test/_search'-d')  
> > {  
> > "size" : 0,  
> > "query" : {  
> > "match\_all" : { }  
> > },  
> > "facets" : {  
> > "tag" : {  
> > "terms" : {  
> > "field" : "text",  
> > "size" : 10000  
> > }  
> > }  
> > } }
> 
> > '
> 
> > will give me terms from field 'text', but how can I get all terms (not  
> > only "size"), alphabetically sorted and with pagination (without Terms  
> > API)?
> 
> > Thanks,  
> > Tomislav

---

<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:** [August 8, 2010, 3:05pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191/4 "2010-08-08T15:05:51Z")

</div>

> will give me terms from field 'text', but how can I get all terms (not  
> only "size"), alphabetically sorted and with pagination (without Terms  
> API)?

I don't think you can, any more.

You would have to use a very large 'size', then sort them alphabetically  
in your client.

This seems an unusual use case though. Why do you need to display  
(potentially) millions of terms?

Surely the user really just wants a list of (eg) 10, which are the most  
frequently used?

clint

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 8, 2010, 8:00pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191/5 "2010-08-08T20:00:43Z")

</div>

I have been enhancing the terms facet in master (0.9.1). For example, you  
can now sort by terms and not just count. And you can use a regex to control  
the what terms gets included.

-shay.banon

On Sun, Aug 8, 2010 at 6:05 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> > will give me terms from field 'text', but how can I get all terms (not  
> > only "size"), alphabetically sorted and with pagination (without Terms  
> > API)?
> 
> I don't think you can, any more.
> 
> You would have to use a very large 'size', then sort them alphabetically  
> in your client.
> 
> This seems an unusual use case though. Why do you need to display  
> (potentially) millions of terms?
> 
> Surely the user really just wants a list of (eg) 10, which are the most  
> frequently used?
> 
> clint

---

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [August 9, 2010, 11:30am UTC](https://discuss.elastic.co/t/missing-terms-api/3191/6 "2010-08-09T11:30:44Z")

</div>

Hi Clint,

On Sun, 2010-08-08 at 17:05 +0200, Clinton Gormley wrote:

> > will give me terms from field 'text', but how can I get all terms (not  
> > only "size"), alphabetically sorted and with pagination (without Terms  
> > API)?
> 
> I don't think you can, any more.
> 
> You would have to use a very large 'size', then sort them alphabetically  
> in your client.
> 
> This seems an unusual use case though. Why do you need to display  
> (potentially) millions of terms?
> 
> Surely the user really just wants a list of (eg) 10, which are the most  
> frequently used?

I understand your point of view when considering faceting, but this  
requirement is more in direction of simple auto suggest/dictionary (with  
terms from index), where you need to display all terms not only most  
popular ones (and restrict/narrow results by prefix).

Like from Terms API definition: 'This can be very handy to implement  
things like tag clouds or simple auto suggest.'

(tag clouds can be implemented by facets as they are)

Tomislav

> clint

---

<div class="post-metadata">

**Author:** ![Tomislav\_Poljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomislav_poljak/32/1177_2.png) [@Tomislav\_Poljak](https://discuss.elastic.co/u/Tomislav_Poljak)\
**Post date:** [August 9, 2010, 11:53am UTC](https://discuss.elastic.co/t/missing-terms-api/3191/7 "2010-08-09T11:53:47Z")

</div>

Hi Shay,  
sounds great!

I've tested regex param in terms facets on latest master and it works as  
expected.

Is 'sort' feature released into current master? I'm asking because I've  
downloaded latest master and build-ed from source and for query like:

curl -XGET '[http://localhost:9200/index/type/\_search](http://localhost:9200/index/type/_search)' -d '  
{  
"query" : {  
"match\_all" : { }  
},  
"facets" : {  
"tag" : {  
"terms" : {  
"field" : "text",  
"regex" : "a.\*",  
"size" : 1000,  
"sort" : "term"  
}  
}  
}  
}  
'

I didn't get results (terms) alphabetically sorted in response (they  
were sorted by count). Did I maybe misplaced/misused 'sort' param in  
query request?

Tomislav

On Sun, 2010-08-08 at 23:00 +0300, Shay Banon wrote:

> I have been enhancing the terms facet in master (0.9.1). For example,  
> you can now sort by terms and not just count. And you can use a regex  
> to control the what terms gets included.
> 
> -shay.banon
> 
> On Sun, Aug 8, 2010 at 6:05 PM, Clinton Gormley  
> [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:
> 
> ```
> > will give me terms from field 'text', but how can I get all
> terms (not
> > only "size"), alphabetically sorted and with pagination
> (without Terms
> > API)?
>     
>     
> I don't think you can, any more.
>     
> You would have to use a very large 'size', then sort them
> alphabetically
> in your client.
>     
> This seems an unusual use case though. Why do you need to
> display
> (potentially) millions of terms?
>     
> Surely the user really just wants a list of (eg) 10, which are
> the most
> frequently used?
>     
> clint
> 
> ```

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 9, 2010, 2:18pm UTC](https://discuss.elastic.co/t/missing-terms-api/3191/8 "2010-08-09T14:18:30Z")

</div>

Its actually called "order", here is the issue:  
[Issues · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/closed#issue/303).

On Mon, Aug 9, 2010 at 2:53 PM, Tomislav Poljak [tpoljak@gmail.com](mailto:tpoljak@gmail.com) wrote:

> Hi Shay,  
> sounds great!
> 
> I've tested regex param in terms facets on latest master and it works as  
> expected.
> 
> Is 'sort' feature released into current master? I'm asking because I've  
> downloaded latest master and build-ed from source and for query like:
> 
> curl -XGET '[http://localhost:9200/index/type/\_search](http://localhost:9200/index/type/_search)' -d '  
> {  
> "query" : {  
> "match\_all" : { }  
> },  
> "facets" : {  
> "tag" : {  
> "terms" : {  
> "field" : "text",  
> "regex" : "a.\*",  
> "size" : 1000,  
> "sort" : "term"  
> }  
> }  
> }  
> }  
> '
> 
> I didn't get results (terms) alphabetically sorted in response (they  
> were sorted by count). Did I maybe misplaced/misused 'sort' param in  
> query request?
> 
> Tomislav
> 
> On Sun, 2010-08-08 at 23:00 +0300, Shay Banon wrote:
> 
> > I have been enhancing the terms facet in master (0.9.1). For example,  
> > you can now sort by terms and not just count. And you can use a regex  
> > to control the what terms gets included.
> > 
> > -shay.banon
> > 
> > On Sun, Aug 8, 2010 at 6:05 PM, Clinton Gormley  
> > [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:
> > 
> > ```
> > > will give me terms from field 'text', but how can I get all
> > terms (not
> > > only "size"), alphabetically sorted and with pagination
> > (without Terms
> > > API)?
> > 
> > I don't think you can, any more.
> > 
> > You would have to use a very large 'size', then sort them
> > alphabetically
> > in your client.
> > 
> > This seems an unusual use case though. Why do you need to
> > display
> > (potentially) millions of terms?
> > 
> > Surely the user really just wants a list of (eg) 10, which are
> > the most
> > frequently used?
> > 
> > clint
> > 
> > ```

---

<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, 4:21am UTC](https://discuss.elastic.co/t/missing-terms-api/3191/9 "2017-07-06T04:21:03Z")

</div>


