# Setting tags for entries

**URL:** <https://discuss.elastic.co/t/setting-tags-for-entries/9440>\
**Category:** Elasticsearch\
**Created:** [October 22, 2012, 9:33pm UTC](https://discuss.elastic.co/t/setting-tags-for-entries/9440 "2012-10-22T21:33:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kostiantyn\_Kahanskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kostiantyn_kahanskyi/32/2617_2.png) [@Kostiantyn\_Kahanskyi](https://discuss.elastic.co/u/Kostiantyn_Kahanskyi)\
**Post date:** [October 22, 2012, 9:33pm UTC](https://discuss.elastic.co/t/setting-tags-for-entries/9440/1 "2012-10-22T21:33:49Z")

</div>

Hello,

I would appreciate any help with the following...

I have two types: "entry" and "tag". A "tag" can be "online" or "offline"  
(boolean property "online").  
I want to do 2 things:

(1) For every "tag" I want to search the "entries" and if any found for a  
specific "tag", I want to mark this "tag" as "online".  
(2) I want to search the "entries" by an arbitrary query. And for every  
found "entry" I want to display two "tags", which have been marked  
"online", while searching for this "entry" in step 1.

How to do (1) I know: I just do a search in "entries" for every tag and  
then update it's property "online" if any "entries" have been found.  
Now the hard one: how can I achieve (2)?

Unfortunately I have hundreds of thousands of entries and thousands of  
"tags". So to set for every "entry" some property of a kind "this entry was  
found for the tag X" is not an option.

Thanx a lot for any kind of help!

Kind regards!  
Kostia

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 22, 2012, 10:17pm UTC](https://discuss.elastic.co/t/setting-tags-for-entries/9440/2 "2012-10-22T22:17:56Z")

</div>

What if you will modify (1) to store the list of entries that caused this  
tag to be "online"? Then in (2) you can first get the list of entries using  
arbitrary query and then for each entry you can execute a search to get two  
corresponding tags. With multi search API it can be implemented with only  
two round trips to the elasticsearch server.

On Monday, October 22, 2012 5:33:49 PM UTC-4, Kostiantyn Kahanskyi wrote:

> Hello,
> 
> I would appreciate any help with the following...
> 
> I have two types: "entry" and "tag". A "tag" can be "online" or "offline"  
> (boolean property "online").  
> I want to do 2 things:
> 
> (1) For every "tag" I want to search the "entries" and if any found for a  
> specific "tag", I want to mark this "tag" as "online".  
> (2) I want to search the "entries" by an arbitrary query. And for every  
> found "entry" I want to display two "tags", which have been marked  
> "online", while searching for this "entry" in step 1.
> 
> How to do (1) I know: I just do a search in "entries" for every tag and  
> then update it's property "online" if any "entries" have been found.  
> Now the hard one: how can I achieve (2)?
> 
> Unfortunately I have hundreds of thousands of entries and thousands of  
> "tags". So to set for every "entry" some property of a kind "this entry was  
> found for the tag X" is not an option.
> 
> Thanx a lot for any kind of help!
> 
> Kind regards!  
> Kostia

--

---

<div class="post-metadata">

**Author:** ![Kostiantyn\_Kahanskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kostiantyn_kahanskyi/32/2617_2.png) [@Kostiantyn\_Kahanskyi](https://discuss.elastic.co/u/Kostiantyn_Kahanskyi)\
**Post date:** [October 22, 2012, 10:33pm UTC](https://discuss.elastic.co/t/setting-tags-for-entries/9440/3 "2012-10-22T22:33:53Z")

</div>

Hello,

thanx a lot for the quick response! :-)))

Great idea!  
But if I would do what you suppose, it would mean, that there will be  
"tags" with about 4.000 ids of "entries". Could it be a performance problem?

Thanx a lot!  
Kostia

Am Dienstag, 23. Oktober 2012 00:17:56 UTC+2 schrieb Igor Motov:

> What if you will modify (1) to store the list of entries that caused this  
> tag to be "online"? Then in (2) you can first get the list of entries using  
> arbitrary query and then for each entry you can execute a search to get two  
> corresponding tags. With multi search API it can be implemented with only  
> two round trips to the elasticsearch server.
> 
> On Monday, October 22, 2012 5:33:49 PM UTC-4, Kostiantyn Kahanskyi wrote:
> 
> > Hello,
> > 
> > I would appreciate any help with the following...
> > 
> > I have two types: "entry" and "tag". A "tag" can be "online" or "offline"  
> > (boolean property "online").  
> > I want to do 2 things:
> > 
> > (1) For every "tag" I want to search the "entries" and if any found for a  
> > specific "tag", I want to mark this "tag" as "online".  
> > (2) I want to search the "entries" by an arbitrary query. And for every  
> > found "entry" I want to display two "tags", which have been marked  
> > "online", while searching for this "entry" in step 1.
> > 
> > How to do (1) I know: I just do a search in "entries" for every tag and  
> > then update it's property "online" if any "entries" have been found.  
> > Now the hard one: how can I achieve (2)?
> > 
> > Unfortunately I have hundreds of thousands of entries and thousands of  
> > "tags". So to set for every "entry" some property of a kind "this entry was  
> > found for the tag X" is not an option.
> > 
> > Thanx a lot for any kind of help!
> > 
> > Kind regards!  
> > Kostia

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 22, 2012, 11:06pm UTC](https://discuss.elastic.co/t/setting-tags-for-entries/9440/4 "2012-10-22T23:06:23Z")

</div>

Could it be a performance problem? It really depends on your requirements,  
available hardware and how often you are planning to update this  
index. Indexing a tag with 4000 ids would be roughly equivalent to indexing  
a document with 4000 words, which elasticsearch can easily handle. But if,  
for example, you have near real-time requirements, performance, indeed,  
might be an issue.

On Monday, October 22, 2012 6:33:53 PM UTC-4, Kostiantyn Kahanskyi wrote:

> Hello,
> 
> thanx a lot for the quick response! :-)))
> 
> Great idea!  
> But if I would do what you suppose, it would mean, that there will be  
> "tags" with about 4.000 ids of "entries". Could it be a performance problem?
> 
> Thanx a lot!  
> Kostia
> 
> Am Dienstag, 23. Oktober 2012 00:17:56 UTC+2 schrieb Igor Motov:
> 
> > What if you will modify (1) to store the list of entries that caused this  
> > tag to be "online"? Then in (2) you can first get the list of entries using  
> > arbitrary query and then for each entry you can execute a search to get two  
> > corresponding tags. With multi search API it can be implemented with only  
> > two round trips to the elasticsearch server.
> > 
> > On Monday, October 22, 2012 5:33:49 PM UTC-4, Kostiantyn Kahanskyi wrote:
> > 
> > > Hello,
> > > 
> > > I would appreciate any help with the following...
> > > 
> > > I have two types: "entry" and "tag". A "tag" can be "online" or  
> > > "offline" (boolean property "online").  
> > > I want to do 2 things:
> > > 
> > > (1) For every "tag" I want to search the "entries" and if any found for  
> > > a specific "tag", I want to mark this "tag" as "online".  
> > > (2) I want to search the "entries" by an arbitrary query. And for every  
> > > found "entry" I want to display two "tags", which have been marked  
> > > "online", while searching for this "entry" in step 1.
> > > 
> > > How to do (1) I know: I just do a search in "entries" for every tag and  
> > > then update it's property "online" if any "entries" have been found.  
> > > Now the hard one: how can I achieve (2)?
> > > 
> > > Unfortunately I have hundreds of thousands of entries and thousands of  
> > > "tags". So to set for every "entry" some property of a kind "this entry was  
> > > found for the tag X" is not an option.
> > > 
> > > Thanx a lot for any kind of help!
> > > 
> > > Kind regards!  
> > > Kostia

--

---

<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:07am UTC](https://discuss.elastic.co/t/setting-tags-for-entries/9440/5 "2017-07-06T03:07:31Z")

</div>


