Im a newbie to Elasticsearch and trying to understand the basics of it.
I followed the tutorial and installed ES. Now, Im trying to index a document as mentioned here -
https://www.elastic.co/guide/en/elasticsearch/guide/current/_indexing_employee_documents.html
but it throws me error.
Should I create my index first before I try to index the document?
Also, What commands are being used here? Are those CURL commands?
import requests
r = requests.get('http://localhost:9200/megacorp')
print r.status_code
print r.text
r = requests.get('http://localhost:9200/twitter')
print r.status_code
print r.text
~
response
200
{"megacorp":{"aliases":{},"mappings":{"employee":{"properties":{"first_name":{"type":"string"},"last_name":{"type":"string"}}}},"settings":{"index":{"creation_date":"1442881963974","uuid":"5bISz0kqTdyjYgz-Hv548Q","number_of_replicas":"1","number_of_shards":"5","version":{"created":"1070299"}}},"warmers":{}}}
200
{"twitter":{"aliases":{},"mappings":{},"settings":{"index":{"creation_date":"1443018283701","uuid":"3DS6RZPYTWuX0-ah18e-Ww","number_of_replicas":"2","number_of_shards":"3","version":{"created":"1070299"}}},"warmers":{}}}
Error in logs:
SearchRequest@2e5f4063] lastShard [true]
org.elasticsearch.search.SearchParseException: [megacorp][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"facets":{"0":{"date_histogram":{"key_field":"@timestamp","value_field":"primaries.indexing.index_total","interval":"1y"},"global":true,"facet_filter":{"fquery":{"query":{"filtered":{"query":{"query_string":{"query":"_type:indices_stats"}},"filter":{"bool":{"must":[{"match_all":{}}]}}}}}}}},"size":50,"query":{"filtered":{"query":{"query_string":{"query":"_type:cluster_event OR _type:node_event"}},"filter":{"bool":{"must":[{"match_all":{}}]}}}},"sort":[{"@timestamp":{"order":"desc","ignore_unmapped":true}},{"@timestamp":{"order":"desc","ignore_unmapped":true}}]}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:747)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:572)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:544)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:306)
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:231)
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:228)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.search.facet.FacetPhaseExecutionException: Facet [0]: (key) field [@timestamp] not found
at org.elasticsearch.search.facet.datehistogram.DateHistogramFacetParser.parse(DateHistogramFacetParser.java:172)
at org.elasticsearch.search.facet.FacetParseElement.parse(FacetParseElement.java:93)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:731)