git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #55 from centromere/parent-support
5b35552Chris Allen
src/Database/Bloodhound/Client.hs+5−1
@@ -378,7 +378,7 @@ indexDocument (IndexName indexName)
378 (MappingName mappingName) cfg document (DocId docId) =
378 (MappingName mappingName) cfg document (DocId docId) =
379 bindM2 put url (return body)
379 bindM2 put url (return body)
380 where url = addQuery params <$> joinPath [indexName, mappingName, docId]
380 where url = addQuery params <$> joinPath [indexName, mappingName, docId]
381− params = case idsVersionControl cfg of
381+ versionCtlParams = case idsVersionControl cfg of
382 NoVersionControl -> []
382 NoVersionControl -> []
383 InternalVersion v -> versionParams v "internal"
383 InternalVersion v -> versionParams v "internal"
384 ExternalGT (ExternalDocVersion v) -> versionParams v "external_gt"
384 ExternalGT (ExternalDocVersion v) -> versionParams v "external_gt"
@@ -388,6 +388,10 @@ indexDocument (IndexName indexName)
388 versionParams v t = [ ("version", Just $ vt v)
388 versionParams v t = [ ("version", Just $ vt v)
389 , ("version_type", Just t)
389 , ("version_type", Just t)
390 ]
390 ]
391+ parentParams = case idsParent cfg of
392+ Nothing -> []
393+ Just (DocumentParent (DocId p)) -> [ ("parent", Just p) ]
394+ params = versionCtlParams ++ parentParams
391 body = Just (encode document)
395 body = Just (encode document)
392
396
393-- | 'deleteDocument' is the primary way to delete a single document.
397-- | 'deleteDocument' is the primary way to delete a single document.
src/Database/Bloodhound/Types.hs+12−5
@@ -63,6 +63,7 @@ module Database.Bloodhound.Types
63 , DocVersion
63 , DocVersion
64 , ExternalDocVersion(..)
64 , ExternalDocVersion(..)
65 , VersionControl(..)
65 , VersionControl(..)
66+ , DocumentParent(..)
66 , IndexDocumentSettings(..)
67 , IndexDocumentSettings(..)
67 , Query(..)
68 , Query(..)
68 , Search(..)
69 , Search(..)
@@ -457,18 +458,24 @@ data VersionControl = NoVersionControl
457 -- care, as this could result in data loss.
458 -- care, as this could result in data loss.
458 deriving (Show, Eq, Ord)
459 deriving (Show, Eq, Ord)
459
460
461+{-| 'DocumentParent' is used to specify a parent document.
462+-}
463+newtype DocumentParent = DocumentParent DocId
464+ deriving (Eq, Show)
465+
460{-| 'IndexDocumentSettings' are special settings supplied when indexing
466{-| 'IndexDocumentSettings' are special settings supplied when indexing
461a document. For the best backwards compatiblity when new fields are
467a document. For the best backwards compatiblity when new fields are
462added, you should probably prefer to start with 'defaultIndexDocumentSettings'
468added, you should probably prefer to start with 'defaultIndexDocumentSettings'
463-}
469-}
464−data IndexDocumentSettings = IndexDocumentSettings {
470+data IndexDocumentSettings =
465− idsVersionControl :: VersionControl
471+ IndexDocumentSettings { idsVersionControl :: VersionControl
466− }
472+ , idsParent :: Maybe DocumentParent
473+ } deriving (Eq, Show)
467
474
468−{-| Reasonable default settings. Chooses no version control.
475+{-| Reasonable default settings. Chooses no version control and no parent.
469-}
476-}
470defaultIndexDocumentSettings :: IndexDocumentSettings
477defaultIndexDocumentSettings :: IndexDocumentSettings
471−defaultIndexDocumentSettings = IndexDocumentSettings NoVersionControl
478+defaultIndexDocumentSettings = IndexDocumentSettings NoVersionControl Nothing
472
479
473{-| 'Sort' is a synonym for a list of 'SortSpec's. Sort behavior is order
480{-| 'Sort' is a synonym for a list of 'SortSpec's. Sort behavior is order
474 dependent with later sorts acting as tie-breakers for earlier sorts.
481 dependent with later sorts acting as tie-breakers for earlier sorts.