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

4 July 2013

Useful link: Tutorial for Elasticsearch

ElasticSearch is an amazing search engine with a REST API .It is open source .. and it is for FREE.

How to learn it?
Best tutorial so far is this blog entry:  http://joelabrahamsson.com/elasticsearch-101/ written by Joel Abrahamsson.

Link:  http://joelabrahamsson.com/elasticsearch-101/

(Ages ago, I wrote  very simple tutorial that cover installation process and basics too,but my was step-by-step ,boring and pictureless. Joel Abrahamsson wrote really amazing tutorial and I wish to have time to do in similar way :) ).

3 October 2011

How to store index in memory in elasticsearch?

Solutions works* for elasticsearch 0.13.1 and higher ( and probably for lower version,but i haven't checked)

 If you want  index to be stored in memory then
If you use  yml config :
index:
   store:
     type: memory


If you use json config
"store": {
  "type": "memory"
}

If you curl extreme fanatic :
somehow

If elasticsearch is run from commandline in linux: :
bin/elasticsearch -f -Xmx2g -Xms2g -Des.index.storage.type=memory
 
* Do NOT use this, if you using local gateway (which is the default settings as well!),because it will not work correctly.,because   kmichy (creator of elasticsearch,who getting moody, when people ask him about solr)  said on elasticsearch that: "If you use index.store.type set to memory (which has some problems in the implementation that I have not tracked yet), then using local gateway (the default) will not work. Once you create an index with settings, they are set to those settings, so if you kill elasticsearch and start it again (with local gateway), you will get failures. If you want a clean elasticsearch instance, delete teh data dir."

example of configuration file for elasticsearch as json

Solution for  elasticsearch 0.13.1 as JSON file (i used default values only)

If you look for YML configuration example,then go this page:
https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml

Some general information about configuration can be found:
http://www.elasticsearch.org/guide/reference/setup/configuration.html
and here:
http://www.elasticsearch.org/guide/


{
"gateway": {
  "type": "fs", //shared file system
   "fs": {
     "location": "/opt/elasticsearch/data/cluster" //locaction of shared file system
"recover_after_nodes": 1,
"expected_nodes": 1,
"recover_after_time": "5m"
},

"cluster": {
"name": "dom"
},

"node": {
"data": true,
"master": true
},

"index": {
"number_of_shards" : 1,
"number_of_replicas" : 3
},

"bootstrap": {
"mlockall": true
},

"http": {
"enabled": true,
"port": 9200
},

"index": {
"number_of_shards": 1,
"number_of_replicas" :3
},

"node": {
"data": true,
"master": true
},
"store": {
"type": "memory",
"cacheSize": "100m",
"bufferSize": "10k"
},
"transport": {
"port": 9300,
"tcp": {
"compress": true
}
},
"routing": {
"allocation": {
"node_initial_primaries_recoveries" : 4,
"node_concurrent_recoveries": 2
}
}
}

29 September 2011

Can i change shards after they have been created ?

Number of shards are static,which means you can't change the number of shards.
You can work around the limit by creating another index, since you can search across indices.

source: elasticsearch@GoogleGroups

6 September 2011

How to get settings for specific index in ElasticSearch?

Solution works for ElasticSearch 0.13.1(it should works with newer and older version )

Let's say that you have index at   /blog/user/ on  your server (for example   http://localhost:9200/) so to get settings you need input:

$ curl -XGET 'http://localhost:9200/blog/user/_settings?pretty=yes'

  ?pretty=yes - I used to make result more readable

How to install elasticsearch on windows and with basic usage using cygwin on windows ?

This solution based on 
Elasticsearch 0.13.1 (and 0.17.6) and Cygwin 1.7.0 for WINDOWS

INFORMATION: (This blog entry is out of date! However, here you can find amazing blog entry with simple tutorial about elasticsearch (It works with Elasticsearch 0.90.2) :  http://joelabrahamsson.com/elasticsearch-101/ )


First.... Kimchy (author of Elasticsearch) wrote "First of all, DON’T PANIC. It will take 5 minutes to get the gist of what ElasticSearch is all about." ... and i agree that you will DON'T PANIC ... but ... it will be SHAMBOLIC EXPERIENCE which looks like cleaning after shit hit the fan.

Let's start from install Cygwin first

1. Download Cygiwn from http://www.cygwin.com/ (Main website , press on setup.exe
2. Run setup.exe and press Next
3. Choose Install from Internet (or if you have Cygwin stuff from other resouces use Install from Local directory ). Press Next
4. Set Root Directory ( i suggest to use path without spaces like: C:\cygwin ) and press Next
5. Set Local Package directory (where all downloaded stuff will be stored , I used my installs folder for that (C:\backup\installs\system\ ) and press Next
6. Select you Internet connection (i don't know your internet settings ) and press next
7. Select any ... any mirror (I using cygwin.cict.fr because it usually work.).Some of them doesn't work sometimes or contain accient version of stuff.
8. Enjoy view of progress of the downloading "list of stuff to install".It should takes a little bit.
IN THE END CYGWIN WILL DISPLAY SETUP ALERT ... so don't have a heart attack.It just inform that you install cygwin first time (really? very clever setup , is it ?) and give you advice that you should ignore this message (so why they display as error message in first place,anyway ?)

9. you should install these stuff :
cygutils(Utils)
vim (Editors)
openssh,openssl,inetutils (Net)
curl (Libs,Net,Web)
uzip(Archive) [u can add gzip and other zip utilities]

and press Next

10.Go prepare dinner , solve few sudokus , solve problems with food in afrikca and do other everyday activity , then afrer that Program should finish installation.

11.Press finish Cygwin

DONE! Now time for Elasticsearch

Suggestion ... ignore what is written about installation on http://www.elasticsearch.org/ and follow installation instruction on https://github.com/elasticsearch/elasticsearch.

12. Download elasticsearch from http://www.elasticsearch.org/download/ using your favorite web browser
(u can use cyqwin if you are commandline fanatic,but it can be a little bit tricky if you are not familiar with cygwin and "linux's life style")

13. Unzip (using windows or archvier software like winzip,winrar and etc) or CYGWIN (command unzip )

14. Then run c:/(installation folder)/bin/elasticsearch.bat on windows.

15. Run Cygwin (Menustart > All Proograms > Cygwin > Cygwin Bash Shell

16. curl -X GET http://localhost:9200/

17.
To put stuff
example 1)
curl -XPUT 'http://localhost:9200/blog/user/steven' -d '{ "name" : "Steven Segal" , "usertype" : "Superhero" }'

Respond should looks moreless like that:

{"ok":true,"_index":"blog","_type":"user","_id":"steven"}

example 2a)
curl -XPUT 'http://localhost:9200/blog/steven/2011/001' -d '
{
"user": "steven",
"title": "my dream come true"
"message": "I was hit by train.That was an unforgotten experience for me.I feel now enough powerful to do another romantic comedy movie"
}'

example 2b)
curl -XPUT 'http://localhost:9200/blog/steven/2011/002' -d '
{
"user": "steven",
"title": "hit me baby one more time "
"message": "I have a new next door's imaginary friend."
}'

example 2c)
curl -XPUT 'http://localhost:9200/blog/steven/2011/003' -d '
{
"user": "steven",
"title": "perfection is hard to improve"
"message": "Garfield was right,because i and my movies are perfect and it is hard to improve"
}'


to get stuff

example 1)
curl -XPUT 'http://localhost:9200/blog/user/steven?pretty=true'

Respond should looks moreless like that:
{
"_index" : "blog",
"_type" : "user",
"_id" : "steven", "_source" : {"name" : "Steven segal","usertype": "superhero"
}
}

example 2)
curl -XPUT 'http://localhost:9200/blog/steven/2011/001?pretty=true'
curl -XPUT 'http://localhost:9200/blog/steven/2011/002?pretty=true'
curl -XPUT 'http://localhost:9200/blog/steven/2011/003?pretty=true'
(btw. ?pretty=true is added to display result more nicely)

to search stuff

Answer will looks something like that (moreless)
'
{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.19178301,
"hits" : [ {
"_index" : "blog",
"_type" : "user",
"_id" : "steven",
"_score" : 0.19178301, "_source" : {"name" : "Steven segal","usertype": "superhero"}
} ]
}
}

GOOD LUCK WITH USING ELASTICSEARCH ... REALLY BIG ... HUGE VERY GOOD LUCK with ELASTICSEARCH and improve your patience skills you will need a lot.

BTW. my favorite part found on elasticsearch website

Where to go from here?
We have just covered a very small portion of what ElasticSearch is all about. For more information, please refer to: .
Yes. "a space" is an answer. There is no way to go from there.




if you have any troubles with cygwin. Look to this website : http://www.cygwin.com/faq/faq.setup.html
if you have any troubles with elasticsearc. You are srcrewed up.


Source:

http://www.elasticsearch.org/ (with crap installation guide )

https://github.com/elasticsearch (with useful installation guide)

http://www.cygwin.com/faq/faq.using.html (useful stuff there if you have problems with cygwin)