Saving an elasticsearch query for reuse possible?

87 Views Asked by At

Does anyone know if this is possible? The closest thing I've seen is the save query option in Kibana. But I'd like to have this for Java/Spring. My idea is for users to build their own elasticsearch queries (works!) and I want to add the option to be able to save them for reuse. Does Elasticsearch or a library for Java/Spring support this function? I'm aware of search templates but it seems better for searchbar inputs and not something where a user can 'build' possibly complicated queries at will.

My last-resort-dumb-idea is to just save the entire query DSL as string or json somewhere and just send it again.

1

There are 1 best solutions below

2
Mouad Slimane On

You can store the query in a elasticsearch index by using the field type percolator your index mapping should be somethings like this

{
"mappings": {
"properties": {
"query": { #A
"type": "percolator" #B
},
"tags": { #D
"type": "text"
}
}
}
}