mali
mali

Reputation: 53

How To index data in elastic search

I am newbie in information retrieval domain. My task is to index large raw data in txt format into elasticsearch. I already crawled my data and stored it onto disk.
Now I installed elasticsearch(0.19.9 , I am using windows xp. I set the java_home variable and ran the elasticsearch.bat). After installing elasticsearch I tested it hitting http:/localhost:9200 on browser and got response. Now if I try to create index by using help on elasticsearch website

curl -XPUT http:/localhost:9200/elasticsearch/tweet/1 -d '{
  "post_date": "2009-11-15T14:12:12",
  "message": "Zug Zug",
  "tag": "warcraft"
}'

I get an error, IndexMissingException[elasticsearch]. So I am not able to create index. I am hitting browser directly, instead of using curl.

Upvotes: 4

Views: 1763

Answers (1)

javanna
javanna

Reputation: 60205

The -d option is a curl option used to send the json document as body request. Furthermore, elasticsearch exposes nice REST APIs, which means that you are supposed to use the available http methods depending on the operation you want to do. Creating an index through the Index API requires the use of the PUT http method. You really need to use a REST http client in order to index data in elasticsearch.

After that you can query it directly from the browser if you really want to. You can do it either through the URIRequest or using the provided Query DSL and passing query using the bodyparameter instead of passing it within the request body.

Upvotes: 3

Related Questions