Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed SimpleDB, CloudSearch docs #789

Merged
merged 2 commits into from

3 participants

@srs81

Hello, thanks for the boto library, its really helpful!

I've made some small changes to the SimpleDB and CloudSearch docs:

  • SimpleDB: fixed batch_put_items() name in docs to the correct batch_put_attributes()
  • CloudSearch: fixed indentation for correct formatting in Python docs

Hope this is useful.

srs81 added some commits
@srs81 srs81 Fixed SimpleDB, CloudSearch docs
SimpleDB: changed batch_put_items() to batch_put_attributes()
CloudSearch: added >>> to properly format on Python docs
552ae89
@srs81 srs81 CloudSearch docs
Missed one line
6592784
@gtaylor
Collaborator

Whew, I guess I didn't see how rough of shape that SimpleDB tutorial was in. If @garnaat doesn't beat me to it, I'll get this reviewed and merged tonight.

@srs81

No problem. Its actually not that bad, just found a few small naming and formatting issues that I hoped would be helpful to fix. :)

@garnaat garnaat merged commit 6c1aacd into boto:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 30, 2012
  1. @srs81

    Fixed SimpleDB, CloudSearch docs

    srs81 authored
    SimpleDB: changed batch_put_items() to batch_put_attributes()
    CloudSearch: added >>> to properly format on Python docs
  2. @srs81

    CloudSearch docs

    srs81 authored
    Missed one line
This page is out of date. Refresh to see the latest.
Showing with 43 additions and 43 deletions.
  1. +40 −40 docs/source/cloudsearch_tut.rst
  2. +3 −3 docs/source/simpledb_tut.rst
View
80 docs/source/cloudsearch_tut.rst
@@ -12,32 +12,32 @@ assumes that you have boto already downloaded and installed.
Creating a Domain
-----------------
- import boto
+ >>> import boto
- our_ip = '192.168.1.0'
+ >>> our_ip = '192.168.1.0'
- conn = boto.connect_cloudsearch()
- domain = conn.create_domain('demo')
+ >>> conn = boto.connect_cloudsearch()
+ >>> domain = conn.create_domain('demo')
- # Allow our IP address to access the document and search services
- policy = domain.get_access_policies()
- policy.allow_search_ip(our_ip)
- policy.allow_doc_ip(our_ip)
+ >>> # Allow our IP address to access the document and search services
+ >>> policy = domain.get_access_policies()
+ >>> policy.allow_search_ip(our_ip)
+ >>> policy.allow_doc_ip(our_ip)
- # Create an 'text' index field called 'username'
- uname_field = domain.create_index_field('username', 'text')
+ >>> # Create an 'text' index field called 'username'
+ >>> uname_field = domain.create_index_field('username', 'text')
- # But it would be neat to drill down into different countries
- loc_field = domain.create_index_field('location', 'text', facet=True)
+ >>> # But it would be neat to drill down into different countries
+ >>> loc_field = domain.create_index_field('location', 'text', facet=True)
- # Epoch time of when the user last did something
- time_field = domain.create_index_field('last_activity', 'uint', default=0)
+ >>> # Epoch time of when the user last did something
+ >>> time_field = domain.create_index_field('last_activity', 'uint', default=0)
- follower_field = domain.create_index_field('follower_count', 'uint', default=0)
+ >>> follower_field = domain.create_index_field('follower_count', 'uint', default=0)
- domain.create_rank_expression('recently_active', 'last_activity') # We'll want to be able to just show the most recently active users
+ >>> domain.create_rank_expression('recently_active', 'last_activity') # We'll want to be able to just show the most recently active users
- domain.create_rank_expression('activish', 'text_relevance + ((follower_count/(time() - last_activity))*1000)') # Let's get trickier and combine text relevance with a really dynamic expression
+ >>> domain.create_rank_expression('activish', 'text_relevance + ((follower_count/(time() - last_activity))*1000)') # Let's get trickier and combine text relevance with a really dynamic expression
Viewing and Adjusting Stemming for a Domain
--------------------------------------------
@@ -182,10 +182,10 @@ Adding Documents to the Index
Now, we can add some documents to our new search domain.
- doc_service = domain.get_document_service()
+ >>> doc_service = domain.get_document_service()
- # Presumably get some users from your db of choice.
- users = [
+ >>> # Presumably get some users from your db of choice.
+ >>> users = [
{
'id': 1,
'username': 'dan',
@@ -216,10 +216,10 @@ Now, we can add some documents to our new search domain.
}
]
- for user in users:
- doc_service.add(user['id'], user['last_activity'], user)
+ >>> for user in users:
+ >>> doc_service.add(user['id'], user['last_activity'], user)
- result = doc_service.commit() # Actually post the SDF to the document service
+ >>> result = doc_service.commit() # Actually post the SDF to the document service
The result is an instance of `cloudsearch.CommitResponse` which will
makes the plain dictionary response a nice object (ie result.adds,
@@ -232,33 +232,33 @@ Searching Documents
Now, let's try performing a search.
- # Get an instance of cloudsearch.SearchServiceConnection
- search_service = domain.get_search_service()
+ >>> # Get an instance of cloudsearch.SearchServiceConnection
+ >>> search_service = domain.get_search_service()
- # Horray wildcard search
- query = "username:'dan*'"
+ >>> # Horray wildcard search
+ >>> query = "username:'dan*'"
- results = search_service.search(bq=query, rank=['-recently_active'], start=0, size=10)
+ >>> results = search_service.search(bq=query, rank=['-recently_active'], start=0, size=10)
- # Results will give us back a nice cloudsearch.SearchResults object that looks as
- # close as possible to pysolr.Results
+ >>> # Results will give us back a nice cloudsearch.SearchResults object that looks as
+ >>> # close as possible to pysolr.Results
- print "Got %s results back." % results.hits
- print "User ids are:"
- for result in results:
- print result['id']
+ >>> print "Got %s results back." % results.hits
+ >>> print "User ids are:"
+ >>> for result in results:
+ >>> print result['id']
Deleting Documents
------------------
- import time
- from datetime import datetime
+ >>> import time
+ >>> from datetime import datetime
- doc_service = domain.get_document_service()
+ >>> doc_service = domain.get_document_service()
- # Again we'll cheat and use the current epoch time as our version number
+ >>> # Again we'll cheat and use the current epoch time as our version number
- doc_service.delete(4, int(time.mktime(datetime.utcnow().timetuple())))
- service.commit()
+ >>> doc_service.delete(4, int(time.mktime(datetime.utcnow().timetuple())))
+ >>> service.commit()
View
6 docs/source/simpledb_tut.rst
@@ -109,11 +109,11 @@ Now let's check if it worked::
Batch Adding Items (and attributes)
-----------------------------------
-You can also add a number of items at the same time in a similar fashion. All you have to provide to the batch_put_items() method
+You can also add a number of items at the same time in a similar fashion. All you have to provide to the batch_put_attributes() method
is a Dictionary-like object with your items and their respective attributes, as follows::
>>> items = {'item1':{'attr1':'val1'},'item2':{'attr2':'val2'}}
- >>> dom.batch_put_items(items)
+ >>> dom.batch_put_attributes(items)
True
>>>
@@ -124,7 +124,7 @@ Now, let's check the item count once again::
3
>>>
-A few words of warning: both batch_put_items() and put_item(), by default, will overwrite the values of the attributes if both
+A few words of warning: both batch_put_attributes() and put_item(), by default, will overwrite the values of the attributes if both
the item and attribute already exist. If the item exists, but not the attributes, it will append the new attributes to the
attribute list of that item. If you do not wish these methods to behave in that manner, simply supply them with a 'replace=False'
parameter.
Something went wrong with that request. Please try again.