Skip to content

Commit

Permalink
Merge pull request #4 from algolia/prepare-js-client-V3
Browse files Browse the repository at this point in the history
prepare readme for JS client V3 release
  • Loading branch information
Vincent Voyer committed Mar 27, 2015
2 parents e6fda47 + 9698828 commit 8225faa
Showing 1 changed file with 67 additions and 43 deletions.
110 changes: 67 additions & 43 deletions README.md
Expand Up @@ -3,27 +3,15 @@


[Algolia Search](http://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
Algolia's Search API makes it easy to deliver a great search experience in your websites and mobile applications by providing:

* REST and JSON based API
* Search against infinite attributes from a single search box
* Instant search as you type experience
* Relevance and popularity ranking
* Global language support
* Typo tolerance in any language
* Smart highlighting
* Facet as you type
* Geo awareness
* 99.99% SLA
* First class data security

Our Java client lets you easily use the [Algolia Search API](http://www.algolia.com) from your Java Application. It wraps the [Algolia Search REST API](http://www.algolia.com/doc/rest_api).
Our Java client lets you easily use the [Algolia Search API](https://www.algolia.com/doc/rest_api) from your Java Application. It wraps the [Algolia Search REST API](http://www.algolia.com/doc/rest_api).


[![Build Status](https://travis-ci.org/algolia/algoliasearch-client-java.png?branch=master)](https://travis-ci.org/algolia/algoliasearch-client-java) [![GitHub version](https://badge.fury.io/gh/algolia%2Falgoliasearch-client-java.png)](http://badge.fury.io/gh/algolia%2Falgoliasearch-client-java) [![Coverage Status](https://coveralls.io/repos/algolia/algoliasearch-client-java/badge.png)](https://coveralls.io/r/algolia/algoliasearch-client-java)




Table of Contents
=================
**Getting Started**
Expand Down Expand Up @@ -83,6 +71,9 @@ Initialize the client with your Application ID and API Key. You can find them on






Quick Start
-------------

Expand Down Expand Up @@ -138,25 +129,35 @@ System.out.println(index.search(new Query("jim")));

**Notes:** If you are building a web application, you may be more interested in using our [JavaScript client](https://github.com/algolia/algoliasearch-client-js) to perform queries. It brings two benefits:
* Your users get a better response time by not going through your servers
* It will offload unnecessary tasks from your servers.
* It will offload unnecessary tasks from your servers

```html
<script type="text/javascript" src="//path/to/algoliasearch.min.js"></script>
<script type="text/javascript">
var client = new AlgoliaSearch("YourApplicationID", "YourSearchOnlyAPIKey");
var index = client.initIndex('YourIndexName');
function searchCallback(success, content) {
if (success) {
console.log(content);
}
<script src="//cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
<script>
var client = algoliasearch('ApplicationID', 'Search-Only-API-Key');
var index = client.initIndex('indexName');
// perform query "jim"
index.search('jim', searchCallback);
// the last optional argument can be used to add search parameters
index.search(
'jim', {
hitsPerPage: 5,
facets: '*',
maxValuesPerFacet: 10
},
searchCallback
);
function searchCallback(err, content) {
if (err) {
console.error(err);
return;
}
// perform query "jim"
index.search("jim", searchCallback);
// the last optional argument can be used to add search parameters
index.search("jim", searchCallback, { hitsPerPage: 5, facets: '*', maxValuesPerFacet: 10 });
console.log(content);
}
</script>
```

Expand Down Expand Up @@ -399,7 +400,7 @@ System.out.println(index.search(new Query("query string").

The server response will look like:

```javascript
```json
{
"hits": [
{
Expand Down Expand Up @@ -470,6 +471,7 @@ index.getObject("myID", Arrays.asList("firstname"));

You can also retrieve a set of objects:


```java
index.getObjects(Arrays.asList("myObj1", "myObj2"));
```
Expand All @@ -478,6 +480,7 @@ index.getObjects(Arrays.asList("myObj1", "myObj2"));




Delete an object
-------------

Expand Down Expand Up @@ -744,15 +747,23 @@ You may have a single index containing per user data. In that case, all records
String publicKey = client.generateSecuredApiKey("YourSearchOnlyApiKey", "(public,user_42)");
```

This public API key must then be used in your JavaScript code as follow:
This public API key can then be used in your JavaScript code as follow:

```javascript
<script type="text/javascript">
var algolia = new AlgoliaSearch('YourApplicationID', '<%= public_api_key %>');
algolia.setSecurityTags('(public,user_42)'); // must be same than those used at generation-time
algolia.initIndex('YourIndex').search($('#q').val(), function(success, content) {
// [...]
});
var client = algoliasearch('YourApplicationID', '<%= public_api_key %>');
client.setSecurityTags('(public,user_42)'); // must be same than those used at generation-time

var index = client.initIndex('indexName')

index.search('something', function(err, content) {
if (err) {
console.error(err);
return;
}

console.log(content);
});
</script>
```

Expand All @@ -765,16 +776,28 @@ You can mix rate limits and secured API keys by setting an extra `user_token` at
String publicKey = client.generateSecuredApiKey("YourSearchOnlyApiKey", "(public,user_42)", "42");
```

This public API key must then be used in your JavaScript code as follow:
This public API key can then be used in your JavaScript code as follow:

```javascript
<script type="text/javascript">
var algolia = new AlgoliaSearch('YourApplicationID', '<%= public_api_key %>');
algolia.setSecurityTags('(public,user_42)'); // must be same than those used at generation-time
algolia.setUserToken('user_42') // must be same than the one used at generation-time
algolia.initIndex('YourIndex').search($('#q').val(), function(success, content) {
// [...]
});
var client = algoliasearch('YourApplicationID', '<%= public_api_key %>');

// must be same than those used at generation-time
client.setSecurityTags('(public,user_42)');

// must be same than the one used at generation-time
client.setUserToken('user_42');

var index = client.initIndex('indexName')

index.search('another query', function(err, content) {
if (err) {
console.error(err);
return;
}

console.log(content);
});
</script>
```

Expand Down Expand Up @@ -848,3 +871,4 @@ client.getLogs(0, 100);

0 comments on commit 8225faa

Please sign in to comment.