Elastic Search : Create Index and Search Index

Creating indexwatch full The Great Wall film online

It is very easy to create index in elastic search. There are various php api/lib available couple of most used are …

https://github.com/nervetattoo/elasticsearch
https://github.com/ruflin/Elastica

curl -XPUT 'http://localhost:9200/database/user/1' -d '
{
"user_login": "appa",
"name": "Appasaheb Sawant",
"postDate": "2013-03-11",
"body": "I am a Sr. Software Engineer." ,
"email": "appasaheb.sawant@gmail.com"
}'

//Command Output

{"ok":true,"_index":"database","_type":"user","_id":"1","_version":2}


curl -XPUT 'http://localhost:9200/database/user/2' -d '
{
"user_login": "sarita",
"name": "Sarita Sawant",
"postDate": "2013-03-25",
"body": "I am a Payroll Assistant",
"email": "test@gmail.com"
}'

//Command Output

{"ok":true,"_index":"database","_type":"user","_id":"2","_version":1}

//Search Index

http://127.0.0.1:9200/database/user/1
http://127.0.0.1:9200/database/user/2
http://127.0.0.1:9200/database/user/_search?q=body:software
http://127.0.0.1:9200/database/user/_search?q=-body:engineer
http://127.0.0.1:9200/database/user/_search?q=user_login:sarita&body:software&pretty=true

Categories: Elasticsearch, Linux, Website Peformance