# Classification Pattern: Percolate, Tag, Index

**URL:** <https://discuss.elastic.co/t/classification-pattern-percolate-tag-index/18530>\
**Category:** Elasticsearch\
**Created:** [July 8, 2014, 2:29pm UTC](https://discuss.elastic.co/t/classification-pattern-percolate-tag-index/18530 "2014-07-08T14:29:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Passaro](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@Peter\_Passaro](https://discuss.elastic.co/u/Peter_Passaro)\
**Post date:** [July 8, 2014, 2:29pm UTC](https://discuss.elastic.co/t/classification-pattern-percolate-tag-index/18530/1 "2014-07-08T14:29:57Z")

</div>

I'm fairly new to Elasticsearch and I'm looking for suggestions on the best  
pattern to execute something similar to what I've done with other systems.  
I have a set of fairly complex queries (for about 10 categories) based on a  
slightly modified version of the Lucene query language. For each new  
document coming into my system I want to match against those queries, then  
tag any matching documents appropriately.

So far, it looks like the pattern I should be using is to percolate docs  
with the classification queries, insert a classification tag array on docs  
outside of ES, and then index them based on the tags.

My questions:

1. Is this the most efficient usage pattern for classification in general?  
I'm particularly concerned about the round trip of having to come out of ES  
to write tags on to docs.

2. The most straightforward choice for implementing my existing queries is  
the Query String Query, but I'll likely need to combine a couple different  
query types to get the same functionality as my existing rules. These  
include a complex set of nested booleans and spans (to catch things like  
negations and intensifiers of my terms of interest), wildcards, and  
regexes. Any good sources of advice/tools out there on efficiently building  
and executing complex queries such as these in ES?

3. I think the answer is no, but is there any way to tag a document (e.g.  
via a script) during percolation?

4. Is there any way to reduce these to a single call? (percolate, tag, and  
index in one go) Thinking about a plugin here if one doesn't already exist.

--  
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/a9910e36-ea7d-49a5-a14f-69c154cc8855%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a9910e36-ea7d-49a5-a14f-69c154cc8855%40googlegroups.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, 1:17am UTC](https://discuss.elastic.co/t/classification-pattern-percolate-tag-index/18530/2 "2017-07-06T01:17:17Z")

</div>


