# Feature request: Ability to save partial queries to abstract search details

**URL:** https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787
**Category:** Elasticsearch
**Created:** [November 21, 2012, 10:06pm UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787 "2012-11-21T22:06:52Z")
**Posts on this page:** 6
**Page:** 1

<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: [November 21, 2012, 10:06pm UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787/1 "2012-11-21T22:06:52Z")

</div>

Hey!  
Wanted to throw this idea out there to see if it would be useful to  
others. I think it'd be very nice to be able to save query/partial queries  
that that can then be re-used. This would allow inputs in web  
code/application to be abstracted away from some of the nitty gritty  
implementation details and provide a cleaner overall interface.  
Furthermore, the search behavior could be tweaked via updating the  
configuration instead of changing code.

The way to do it is to have pseudo fields (defined in the mapping) and  
saved named queries (that reference the psuedo field they belong to) that  
can be passed in as inputs for that psuedo field, eg:  
FieldName: NewsType

FieldValues:  
Announcements = feedid:(1323 OR 1330) AND NOT headline:"test message"  
News = feedid:600 AND providercode:"6003"  
BreakingNews = feedid:600 AND providercode:"6003" AND hotnews:1

So, an example query would simply be:  
NewsType:BreakingNews

It seems similar is already done to some extent with percolation and that  
same pattern could likely be used.

Thanks!  
Paul

--

---

<div class="post-metadata">

### Author: ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)
#### Post date: [November 25, 2012, 4:21am UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787/2 "2012-11-25T04:21:59Z")

</div>

Seems useful to me... though I wonder if this really needs to live in ES,  
or whether it should just be built on top of it.

## Otis

ELASTICSEARCH Performance Monitoring - [Sematext Monitoring | Infrastructure Monitoring Service](http://sematext.com/spm/index.html)  
Search Analytics - [Cloud Monitoring Tools & Services | Sematext](http://sematext.com/search-analytics/index.html)

On Wednesday, November 21, 2012 5:06:52 PM UTC-5, ppearcy wrote:

> Hey!  
> Wanted to throw this idea out there to see if it would be useful to  
> others. I think it'd be very nice to be able to save query/partial queries  
> that that can then be re-used. This would allow inputs in web  
> code/application to be abstracted away from some of the nitty gritty  
> implementation details and provide a cleaner overall interface.  
> Furthermore, the search behavior could be tweaked via updating the  
> configuration instead of changing code.
> 
> The way to do it is to have pseudo fields (defined in the mapping) and  
> saved named queries (that reference the psuedo field they belong to) that  
> can be passed in as inputs for that psuedo field, eg:  
> FieldName: NewsType
> 
> FieldValues:  
> Announcements = feedid:(1323 OR 1330) AND NOT headline:"test message"  
> News = feedid:600 AND providercode:"6003"  
> BreakingNews = feedid:600 AND providercode:"6003" AND hotnews:1
> 
> So, an example query would simply be:  
> NewsType:BreakingNews
> 
> It seems similar is already done to some extent with percolation and that  
> same pattern could likely be used.
> 
> Thanks!  
> Paul

--

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [November 26, 2012, 9:17am UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787/3 "2012-11-26T09:17:13Z")

</div>

Hi Paul,

I would suggest a query language as a front-end. For example, I have  
implemented an SRU/CQL parser

[http://www.loc.gov/standards/sru/](http://www.loc.gov/standards/sru/)

that translates bibliographic queries to Elasticsearch DSL. CQL is very  
simple compared to ES DSL. Although the translator is using an LALR parser,  
there is somewhat a similarity to your suggestion of building a "macro  
list" of query phrases, but LALR parsers are more powerful.

The advantage of the separation of a front-end query language from the ES  
back-end query language is that you can add or replace the back-end with  
other systems by adapting the translator, so from a front-end view you can  
even do federated search, if the response output formats can be  
consolidated.

Cheers,

Jörg

--

---

<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: [November 27, 2012, 4:58pm UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787/4 "2012-11-27T16:58:17Z")

</div>

Thanks for the feedback. For most cases, I agree doing this front end makes  
more sense. However, when you start saving queries for percolation things  
get more complicated, since you then need to keep the saved sub-queries in  
sync with what is saved down in elasticsearch.

On Monday, November 26, 2012 2:17:13 AM UTC-7, Jörg Prante wrote:

> Hi Paul,
> 
> I would suggest a query language as a front-end. For example, I have  
> implemented an SRU/CQL parser
> 
> [SRU: Search/Retrieval via URL -- SRU, CQL and ZeeRex (Standards, Library of Congress)](http://www.loc.gov/standards/sru/)
> 
> that translates bibliographic queries to Elasticsearch DSL. CQL is very  
> simple compared to ES DSL. Although the translator is using an LALR parser,  
> there is somewhat a similarity to your suggestion of building a "macro  
> list" of query phrases, but LALR parsers are more powerful.
> 
> The advantage of the separation of a front-end query language from the ES  
> back-end query language is that you can add or replace the back-end with  
> other systems by adapting the translator, so from a front-end view you can  
> even do federated search, if the response output formats can be  
> consolidated.
> 
> Cheers,
> 
> Jörg

--

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [November 27, 2012, 6:51pm UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787/5 "2012-11-27T18:51:53Z")

</div>

Do you miss an API for listing the queries in the percolator?

Jörg

--

---

<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:02am UTC](https://discuss.elastic.co/t/feature-request-ability-to-save-partial-queries-to-abstract-search-details/9787/6 "2017-07-06T03:02:37Z")

</div>


