Pages

Showing posts with label elasticsearch. Show all posts
Showing posts with label elasticsearch. Show all posts

Tuesday, January 29, 2013

Access elasticsearch from Amazon EC2

Whatever host you use to connect to your ec2 machine, just add the name of the host and the port as 9200. http://ec2-xyz-ab-gh-io.compute-1.amazonaws.com:9200/

Monday, January 21, 2013

Search query elasticsearch


curl 'http://localhost:9200/blog/post/_search?q=something&pretty=true'

Posting data to elasticsearch

Source: http://www.elasticsearchtutorial.com/elasticsearch-in-5-minutes.html

When the elasticsearch is working you would need to index data to the instance and you will do the same by the following steps.

We're now going to index some data to our ElasticSearch instance. We'll use the example of a blog engine, which has some posts and comments.
curl -XPUT 'http://localhost:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }'

curl -XPUT 'http://localhost:9200/blog/post/1' -d '
{
    "user": "dilbert",
    "postDate": "2011-12-15",
    "body": "Search is hard. Search should be easy." ,
    "title": "On search"
}'


curl -XPUT 'http://localhost:9200/blog/post/2' -d '
{
    "user": "dilbert",
    "postDate": "2011-12-12",
    "body": "Distribution is hard. Distribution should be easy." ,
    "title": "On distributed search"
}'


curl -XPUT 'http://localhost:9200/blog/post/3' -d '
{
    "user": "dilbert",
    "postDate": "2011-12-10",
    "body": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat" ,
    "title": "Lorem ipsum"
}'
To each of these requests, you should have received a response that verifies that the operation was successful, for example:
{"ok":true,"_index":"blog","_type":"post","_id":"1","_version":1}

Check whether elasticsearch is running fine


You can access it at http://localhost:9200 on your web browser, which returns this:
{
  "ok" : true,
  "status" : 200,
  "name" : "Ultra-Marine",
  "version" : {
    "number" : "0.19.0",
    "snapshot_build" : false
  },
  "tagline" : "You Know, for Search"
}

./bin/elasticsearch: 122: exec: : Permission denied



On my local machine

bin/elasticsearch -f

Then go to the following URL http://localhost:9200/blog/post/_search?q=har

But the same is not working on the server!

Error
user@server:/home/ubuntu/elasticsearch-0.19.9# ./bin/elasticsearch -f

This is coming because Java is not installed

Solution
Install Java

./bin/elasticsearch: 122: exec: : Permission denied
The fist step was to install Java on the linux machine. Let's see if that solved the problem. 
Okay! Awesome elasticsearch is working now using the command bin/elasticsearch -f

Monday, November 26, 2012

Highlighting search results with the query term in ElasticSearch


Highlighting search results with the query term in ElasticSearch:

curl -XGET 'http://localhost:9200/document/_search?pretty=true' -d '{
    "query" : { "term" : { "title": "mobile" }},
    "highlight" : {
        "fields" : {
            "text" : {}
        }
    }
}'