Skip to content

Instantly share code, notes, and snippets.

@wireframe
Created February 16, 2011 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wireframe/b5775ddf2160cf9c8dd7 to your computer and use it in GitHub Desktop.
Save wireframe/b5775ddf2160cf9c8dd7 to your computer and use it in GitHub Desktop.
#!/bin/bash
for i in {1..25}
do
echo ''
echo $i
#delete index
curl -XDELETE http://localhost:9200/test
#configure index
curl -XPUT http://localhost:9200/test -d '
{"analysis.analyzer.default.tokenizer":"standard","analysis.analyzer.default.filter":["standard","lowercase","porterStem"]}
'
#index a set of documents
curl -XPUT http://localhost:9200/test/social_objects/113776062 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"Where is HR Located?","bookmark":false,"body":"Id really like to know","blog":false,"attachments":[],"last_interacted_at_to_i":1297875401000,"tag":"","idea":false,"visibility":true,"comments":[{"attachments":[],"user":{"name":"Mike Whittington"},"text":"comment"},{"attachments":[],"user":{"name":"Mike Whittington"},"text":"comment"}],"text":"Where is HR Located?\\n\\nId really like to know","user_id":1,"slides":false,"category_id":767885798,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/375670681 -d '
{"photo":false,"audio":false,"user_name":"Marshall Sellers Admin","attached_file":false,"groups":[],"title":"From Sun","bookmark":false,"body":null,"blog":false,"attachments":[],"last_interacted_at_to_i":1219409566000,"tag":"","idea":false,"visibility":true,"comments":[{"attachments":[],"user":{"name":"Marshall Sellers Admin"},"text":"from sun"}],"text":"From Sun","user_id":13,"slides":false,"category_id":null,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":297062136,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/401421920 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"Where is HR Located?","bookmark":false,"body":"Id really like to know","blog":false,"attachments":[],"last_interacted_at_to_i":1297789061000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"Where is HR Located?\\n\\nId really like to know","user_id":1,"slides":false,"category_id":767885798,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/808934974 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"Where is HR Located?","bookmark":false,"body":"Id really like to know","blog":false,"attachments":[],"last_interacted_at_to_i":1297875401000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"Where is HR Located?\\n\\nId really like to know","user_id":1,"slides":false,"category_id":767885798,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/922175824 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"Where is HR Located?","bookmark":false,"body":"Id really like to know","blog":false,"attachments":[],"last_interacted_at_to_i":1219409566000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"Where is HR Located?\\n\\nId really like to know","user_id":1,"slides":false,"category_id":767885798,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/988396797 -d '
{"photo":false,"audio":false,"user_name":null,"attached_file":false,"groups":[{"name":"Motorola Group"}],"title":null,"bookmark":false,"body":"hello","blog":false,"attachments":[],"last_interacted_at_to_i":1297875401000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"hello","user_id":null,"slides":false,"category_id":null,"video":false,"worklog":false,"question":false,"link":false,"tenant_id":698574893,"group_ids":[715567398],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/1030097467 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"feeding my cat","bookmark":false,"body":null,"blog":false,"attachments":[],"last_interacted_at_to_i":1219409566000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"feeding my cat","user_id":1,"slides":false,"category_id":null,"video":false,"worklog":false,"question":false,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/1047855827 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"Where is HR Located?","bookmark":false,"body":"Id really like to know","blog":false,"attachments":[],"last_interacted_at_to_i":1297875401000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"Where is HR Located?\\n\\nId really like to know","user_id":1,"slides":false,"category_id":767885798,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
#this is the document we search for
curl -XPUT http://localhost:9200/test/social_objects/1047855828 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"i like food","bookmark":false,"body":"","blog":false,"attachments":[],"last_interacted_at_to_i":1297875462000,"tag":"","idea":true,"visibility":true,"comments":[],"text":"i like food","user_id":1,"slides":false,"category_id":null,"video":false,"worklog":false,"question":false,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
curl -XPUT http://localhost:9200/test/social_objects/1047855829 -d '
{"photo":false,"audio":false,"user_name":"Charles Whatley","attached_file":false,"groups":[],"title":"you like food?","bookmark":false,"body":"","blog":false,"attachments":[],"last_interacted_at_to_i":1297875462000,"tag":"","idea":false,"visibility":true,"comments":[],"text":"you like food?","user_id":1,"slides":false,"category_id":null,"video":false,"worklog":false,"question":true,"link":false,"tenant_id":698574893,"group_ids":[],"status_message":false}
'
#refresh the index
curl -XPOST http://localhost:9200/test/_refresh
#search for document 113776062
curl -XGET "http://localhost:9200/test/social_objects/_search?default_operator=AND&fields=_id&q=(+tenant_id:698574893)%20(food)%20(+idea:true)%20(+visibility:true)&from=0&size=20&sort=last_interacted_at_to_i:desc" | grep "\[\]"
#fail if no results returned
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo 'no results found!'
exit 1
else
echo 'results found...'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment