<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Search Nuggets &#187; search templates</title>
	<atom:link href="http://blog.comperiosearch.com/blog/tag/search-templates/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.comperiosearch.com</link>
	<description>A blog about Search as THE solution</description>
	<lastBuildDate>Mon, 13 Jun 2016 08:59:45 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.9.40</generator>
	<item>
		<title>Search templates in elasticsearch</title>
		<link>http://blog.comperiosearch.com/blog/2014/04/11/revised-architecture-for-the-seasonal-recipe-app-elasticsearch-angularjs-search-templates/</link>
		<comments>http://blog.comperiosearch.com/blog/2014/04/11/revised-architecture-for-the-seasonal-recipe-app-elasticsearch-angularjs-search-templates/#comments</comments>
		<pubDate>Fri, 11 Apr 2014 13:56:57 +0000</pubDate>
		<dc:creator><![CDATA[Christoffer Vig]]></dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[AngularJS]]></category>
		<category><![CDATA[Elasticsearch]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[qbox]]></category>
		<category><![CDATA[recipe app]]></category>
		<category><![CDATA[recipes]]></category>
		<category><![CDATA[relevancy]]></category>
		<category><![CDATA[search templates]]></category>

		<guid isPermaLink="false">http://blog.comperiosearch.com/?p=2194</guid>
		<description><![CDATA[Using search templates simplifies the life of the client searcher. Now she can have an elasticsearch query DSL expert create search templates for him, hiding away all the ugly booleans, weightings, facets and what have you, while she relaxes in his armchair emitting simple searches for &#8216;beetroot&#8217; or any other favourite vegetable, fish, meats, dairy, or [...]]]></description>
				<content:encoded><![CDATA[<p>Using <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html#search-template">search templates</a> simplifies the life of the client searcher. Now she can have an elasticsearch query DSL expert create search templates for him, hiding away all the ugly booleans, weightings, facets and what have you, while she relaxes in his armchair emitting simple searches for &#8216;beetroot&#8217; or any other favourite vegetable, fish, meats, dairy, or whatever her search domain requires.</p>
<p>Search templates is a brand new feature  added to elasticsearch version 1.1. 0. It allows potentially complex search logic to be stored as templates. The user sends a query with the parameters that matters for him, along with the name of a search template, and the supplied parameters will be inserted at the proper place on execution.  The template format is <a href="http://mustache.github.io/">moustache</a>, a widely used javascript templating tool.</p>
<p>Cool stuff, you say. How can I use it? And does it really work?</p>
<p>In the current implentation of search templates, you create a JSON request specifying both the template and the parameters.</p>
<script src="https://gist.github.com/10469480.js?file=demo1"></script>
<p>You can save the templates in the config/scripts folder of your elasticsearch installation, and use the saved query.<br />
The template is saved as config/scripts/ingredientsquery.moustache. This is how my template looked like:</p>
<script src="https://gist.github.com/10469480.js?file=template"></script>
<p>And here is a sample query using this template</p>
<script src="https://gist.github.com/10469480.js?file=demo2"></script>
<p>To make changes to the template effective, you need to restart elasticsearch.</p>
<p>You would perhaps expect it to be possible to upload a search template using the REST API.  Unfortunately,  that hasn&#8217;t been implemented yet.  At the moment, you have to store the search templates in the  config/scripts folder in your elasticsearch node.  There is an <a href="https://github.com/elasticsearch/elasticsearch/issues/5637">issue</a> registered to add this feature, but in the mean time, our friends over at <a href="http://qbox.io">qbox</a> are helpful as always and offer to manually place the templates where they belong while we wait for elasticsearch version 1.1.1 (or something).</p>
<p>Using this awesome feature, the only reason we still need some middleware between our elasticsearch installation and our browser is to protect the search service from malicious requests. As it so happens, Qbox have recently added a feature that enables public read only access to the elasticsearch query _search endpoint.</p>
<p>This enables us to use the Qbox elasticsearch service directly from the <a href="http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/index.html">angularjs client for elasticsearch</a>.</p>
<p>Thus we eliminate the need for the searchclient in ruby, and one less server component to care about.</p>
<p>Sounds nice? This is work in progress, so <a href="http://blog.comperiosearch.com/blog/tag/recipe-app/">check back every now and then for new blog posts</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.comperiosearch.com/blog/2014/04/11/revised-architecture-for-the-seasonal-recipe-app-elasticsearch-angularjs-search-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
