Skip to content

Commit

Permalink
adds link to good beginners guide to ES: http://seanmcgary.com/posts/…
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Dec 15, 2014
1 parent d63854a commit 69f4ec1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 36 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-updat

## Background Reading

- Elasticsearch (wiki): http://en.wikipedia.org/wiki/Elasticsearch
- Elasticsearch (wikipedia): http://en.wikipedia.org/wiki/Elasticsearch
- Beginner's Guide to Elasticsearch: http://seanmcgary.com/posts/beginners-guide-to-elasticsearch
- Faceted Search: http://en.wikipedia.org/wiki/Faceted_search
- Solr vs Elasticsearch: http://stackoverflow.com/questions/10213009/solr-vs-elasticsearch
- More detailed Solr vs ES: http://blog.sematext.com/2012/08/23/solr-vs-elasticsearch-part-1-overview
Expand Down
62 changes: 27 additions & 35 deletions insert.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
var querystring = require('querystring'); // to build our post string
var http = require('http');

function insert(id,tweet) {
// Build the post string from an object
var post_data = querystring.stringify({
"tweet" : tweet,
"text" :"my amazing tweet text"
});
var data = JSON.stringify({
"text" :"everything is awesome"
});

// An object of options to indicate where to post to
var post_options = {
host: 'localhost',
port: '9200',
path: '/twitter/tweets/'+id+'/',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': post_data.length
}
};
console.log(' - - - - ');
console.log(post_options);
console.log(' - - - - ');
console.log(post_data);
console.log(' - - - - ');
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// An object of options to indicate where to post to
var post_options = {
host: 'localhost',
port: '9200',
path: '/twitter/tweets/1234',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
}
};

// post the data
post_req.write(post_data);
post_req.end();
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});

}
console.log(data);
console.log(' - - - - ');
console.log(post_options);

insert('1234', 'hello world');
// post the data
post_req.write( data );
post_req.end();

0 comments on commit 69f4ec1

Please sign in to comment.