13. 89
How TO!
1. Simple HTTP call to _search REST API of Elasticsearch
2. Elastic (former Swiftype) Site Search - [https://www.elastic.co/products/site-search]
3. Elastic (former Swiftype) App Search - [https://www.elastic.co/products/app-
search]
4. Custom build solution using Elasticsearch client libraries –
[https://www.elastic.co/guide/en/elasticsearch/client/index.html]
Different solutions for different approach
14. 90
1. Simple HTTP call to _search REST API of Elastic
• No Elasticsearch client library – only HTTP rest api calls
• Using internal (your) programming language http library
• All logic, maintenance and compatibility is on you
• Small app, low number of searches
• Usually simple queries
Good for small apps, rare searches, low search throughput
15. 91
Simple HTTP call to _search REST API of Elastic
Good for small apps, rare searches, low search throughput
curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type:
application/json' -d'
{
"query": {
"match" : {
"message" : {
"query" : "this is a test"
}
}
}
}
'
16. 92
4. Custom built solution using Elasticsearch client
libraries
• Using Elasticsearch client library of your choice
• Complete control over all functionality from indexing and mapping à
• To search queries, scoring, synonyms and results
• Library takes care
‒ of connection pool
‒ helps with building the query
‒ About compatibility with ES versions
• No search UI
• Your focus is functionality of application like with any other library
Great for complete control over all functionality
17. 93
4. Custom built solution using Elasticsearch client
libraries
• Java REST Client
• Java API
• JavaScript API
• Ruby API
• Go API
• .NET API
• PHP API
• Perl API
• Python API
Language clients
19. 95
2. Elastic Site Search
• Great for smaller apps with public access
• Crawler will ingest your entire website into a powerful, relevance-tuned
search engine
• Ckeeps content current
• Almost no development experiences needed
• Easy installation
• Nice UI to tweak and tune your search experience
• Hosted solution – soon also in Elastic cloud
• https://app.swiftype.com/login
Crawl and search your website with ease
20. 96
2. Elastic Site Search
<!DOCTYPE html>
<head>
<script type="text/javascript">
(function (w, d, t, u, n, s, e) {
w['SwiftypeObject'] = n; w[n] = w[n] || function () {
(w[n].q = w[n].q || []).push(arguments);
}; s = d.createElement(t);
e = d.getElementsByTagName(t)[0]; s.async = 1; s.src = u; e.parentNode.insertBefore(s, e);
})(window, document, 'script', '//s.swiftypecdn.com/install/v2/st.js', '_st');
_st('install', '6iuFaExTVvgZ7hMLYixx', '2.0.0');
</script>
</head>
<body>
This is your search page
<form>
<input type="text" class="st-default-search-input">
<button type="submit">Submit</button>
</form>
</body></html>
Code
24. 100
3. Elastic App Search
• Use app-search library, connect to your app, index or search documents
• Seamless scalability
• Tunable relevance controls,
• Thorough documentation
• Well-maintained clients (JavaScript, Node.js, PHP, Python, Ruby)
• Robust analytics with UI
• Hosted (paid) or self-managed – free except few features like SAML
• https://app.swiftype.com/select
Great for any application size