NEST vs. javascript/jquery - Trying to get started


(Daniel Duarte Figueiredo) #1

Hello everyone,
This is my first message here and I am new to ElasticSearch.
I am currently developing an ASP.NET MVC application using the Razor View
Engine.
I'm using an AWS server with two nodes (ec2 small server), using the NGINX
proxy. I configured the server using this tutorial:
http://www.elasticsearch.org/tutorials/2012/03/21/deploying-elasticsearch-with-chef-solo.html

My question is: what is the best way to implement the client-server
communication? I was trying to add a script in my view to put or get
indexes in/from the server,
but I couldn't make it work. Then I read about NEST and it seems pretty
interesting, so what do you think is the best way to start?
Are there any advantages or disadvantages in the use of NEST? How can I
configure the connection using the NGINX proxy (the problems I went through
seem to be
related with the proxy)?


Just to ilustrate how I was trying to make the connection:
I wrote a simple script in my .cshtml file that was supposed to retrieve a
previously created index:

var username="USERNAME";
var password="PASSWORD"

function getElastic() {
jQuery.support.cors = true;
$.ajax({
crossDomain:true,
xhrFields: {
withCredentials: true
},
beforeSend: function (req, settings) {
req.setRequestHeader('Authorization',
make_base_auth(username, password));
},
url:
'http://USERNAME:PASSWORD@SERVER_IP/test_chef_cookbook/document/_search?pretty=true',
type: 'POST',
data: JSON.stringify({
"query": { "match_all": {} }
}),
dataType: 'json',
processData: false,
success: function (json, statusText, xhr) {
alert(json);
return;
},
error: function (xhr, message, error) {
alert(error);
}
});
}


(system) #2