Created
July 4, 2011 06:52
-
-
Save pacoguzman/1062993 to your computer and use it in GitHub Desktop.
ElasticSearch and Couchdb River
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create design documents with the filters | |
curl -vX PUT 'http://127.0.0.1:5984/couchdb_myapp_development/_design/Product' -d '{ | |
"_id": "_design/Product", | |
"language": "javascript", | |
"filters": { | |
"product": "function(doc, req) { return doc['type'] == 'Product'; }" | |
} | |
}' | |
curl -vX PUT 'http://127.0.0.1:5984/couchdb_myapp_development/_design/Person' -d '{ | |
"_id": "_design/Person", | |
"language": "javascript", | |
"filters": { | |
"person": "function(doc, req) { return doc['type'] == 'Person'; }" | |
} | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Store one document | |
curl -X POST 'http://127.0.0.1:5984/couchdb_myapp_development/' -d '{ | |
"_id": "124a10f3b56882607c8f3c89cd053c4c", | |
"type": "Product", | |
"name": "Time Capsule", | |
"description": "La Time Capsule es una estación base Airport completa con un disco duro integrado con la que podrás hacer copias de seguridad de manera inalámbrica y crear una red Wi-Fi con un solo dispositivo." | |
}' | |
# Execute a search query | |
curl -X POST "http://localhost:9200/products/product/_search?pretty=true" -d '{ | |
"query" : { | |
"query_string" : { | |
"query" : "inalámbrica" | |
} | |
} | |
}' => | |
{ | |
"took" : 29, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 1, | |
"max_score" : 0.033902764, | |
"hits" : [ { | |
"_index" : "products", | |
"_type" : "product", | |
"_id" : "124a10f3b56882607c8f3c89cd053c4c", | |
"_score" : 0.033902764, "_source" : {"_rev":"1-34cacc5258bbca9b83bef738a08f155d","_id":"124a10f3b56882607c8f3c89cd053c4c","description":"La Time Capsule es una estación base Airport completa con un disco duro integrado con la que podrás hacer copias de seguridad de manera inalámbrica y crear una red Wi-Fi con un solo dispositivo.","name":"Time Capsule","type":"Product"} | |
} ] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the river for each type of document | |
curl -XPUT 'http://localhost:9200/_river/products/_meta' -d '{ | |
"type" : "couchdb", | |
"couchdb" : { | |
"host" : "localhost", | |
"port" : 5984, | |
"db" : "couchdb_myapp_development", | |
"filter" : "Product/product" | |
}, | |
"index" : { | |
"index" : "products", | |
"type" : "product" | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/_river/people/_meta' -d '{ | |
"type" : "couchdb", | |
"couchdb" : { | |
"host" : "localhost", | |
"port" : 5984, | |
"db" : "couchdb_myapp_development", | |
"filter" : "Person/person" | |
}, | |
"index" : { | |
"index" : "people", | |
"type" : "person" | |
} | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# INSTALL ElasticSearch | |
curl -k -L -# -o elasticsearch-0.16.2.tar.gz \ | |
"http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.16.2.tar.gz" | |
tar -zxf elasticsearch-0.16.2.tar.gz | |
rm -f elasticsearch-0.16.2.tar.gz | |
# INSTALL Couchdb River | |
./elasticsearch-0.16.2/bin/plugin -install river-couchdb | |
# Start ElasticSearch | |
./elasticsearch-0.16.2/bin/elasticsearch -p #{destination_root}/tmp/pids/elasticsearch.pid | |
# Couchdb App Database (couchdb_myapp_development) | |
curl -vX PUT 'http://127.0.0.1:5984/couchdb_myapp_development' | |
# Create river index | |
curl -XPUT 'http://localhost:9200/_river/couchdb_myapp_development_river/_meta' -d '{ | |
"type" : "couchdb", | |
"couchdb" : { | |
"host" : "localhost", | |
"port" : 5984, | |
"db" : "couchdb_myapp_development", | |
"filter" : null | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Glad to help @slorber