mirror of
https://github.com/typeable/bloodhound.git
synced 2025-01-05 21:36:03 +03:00
bulk ops documentation, better bulk tests
This commit is contained in:
parent
1f6b11ccff
commit
eb013371b2
41
README.org
41
README.org
@ -273,6 +273,47 @@ Right (Tweet {user = "bitemyapp"
|
||||
|
||||
#+END_SRC
|
||||
|
||||
** Bulk Operations
|
||||
|
||||
*** Bulk create, index
|
||||
|
||||
#+BEGIN_SRC haskell
|
||||
|
||||
-- don't forget the imports and derive generic setting for ghci
|
||||
-- at the beginning of the examples.
|
||||
|
||||
:{
|
||||
-- Using the earlier Tweet datatype and exampleTweet data
|
||||
|
||||
-- just changing up the data a bit.
|
||||
let bulkTest = exampleTweet { user = "blah" }
|
||||
let bulkTestTwo = exampleTweet { message = "woohoo!" }
|
||||
|
||||
-- create only bulk operation
|
||||
-- BulkCreate :: IndexName -> MappingName -> DocId -> Value -> BulkOperation
|
||||
let firstOp = BulkCreate testIndex
|
||||
testMapping (DocId "3") (toJSON bulkTest)
|
||||
|
||||
-- index operation "create or update"
|
||||
let sndOp = BulkIndex testIndex
|
||||
testMapping (DocId "4") (toJSON bulkTestTwo)
|
||||
|
||||
-- Some explanation, the final "Value" type that BulkIndex,
|
||||
-- BulkCreate, and BulkUpdate accept is the actual document
|
||||
-- data that your operation applies to. BulkDelete doesn't
|
||||
-- take a value because it's just deleting whatever DocId
|
||||
-- you pass.
|
||||
|
||||
-- list of bulk operations
|
||||
let stream = [firstDoc, secondDoc]
|
||||
|
||||
-- Fire off the actual bulk request
|
||||
-- bulk :: Server -> [BulkOperation] -> IO Reply
|
||||
resp <- bulk testServer stream
|
||||
:}
|
||||
|
||||
#+END_SRC
|
||||
|
||||
** Search
|
||||
|
||||
*** Querying
|
||||
|
@ -160,9 +160,9 @@ main = hspec $ do
|
||||
let firstTest = BulkTest "blah"
|
||||
let secondTest = BulkTest "bloo"
|
||||
let firstDoc = BulkIndex testIndex
|
||||
testMapping (DocId "2") (object ["name" .= String "blah"])
|
||||
testMapping (DocId "2") (toJSON firstTest)
|
||||
let secondDoc = BulkCreate testIndex
|
||||
testMapping (DocId "3") (object ["name" .= String "bloo"])
|
||||
testMapping (DocId "3") (toJSON secondTest)
|
||||
let stream = [firstDoc, secondDoc]
|
||||
_ <- bulk testServer stream
|
||||
_ <- refreshIndex testServer testIndex
|
||||
|
Loading…
Reference in New Issue
Block a user