git.iko.soy/typeable/bloodhound
on master help sign in
docs, formatting, renamed createMapping
commit2fffe354d798c82772878ed3ffb316423288026f authorChris Allen <cma@bitemyapp.com> dateSat 14 Jun 2014, 23:38 (12 years ago) parenteedfa5f
6 files changed+16−7
.gitignore+2 Database/Bloodhound/Client.hs+6−2 Database/Bloodhound/Types.hs+5−1 Makefile+1−2 README.org+1−1 tests/tests.hs+1−1
.gitignore+2
@@ -6,3 +6,5 @@ dist/
66.DS_Store
77*.hi
88*.o
9+bloodhound-*-docs/
10+bloodhound-*-docs.tar.gz
Database/Bloodhound/Client.hs+6−2
@@ -138,9 +138,12 @@ openIndex = openOrCloseIndexes OpenIndex
138138closeIndex :: Server -> IndexName -> IO Reply
139139closeIndex = openOrCloseIndexes CloseIndex
140140
141−createMapping :: ToJSON a => Server -> IndexName
141+{-| putMapping is an HTTP PUT and has upsert semantics. Mappings are schemas
142+ for documents in indexes.
143+-}
144+putMapping :: ToJSON a => Server -> IndexName
142145 -> MappingName -> a -> IO Reply
143−createMapping (Server server) (IndexName indexName) (MappingName mappingName) mapping =
146+putMapping (Server server) (IndexName indexName) (MappingName mappingName) mapping =
144147 put url body
145148 where url = joinPath [server, indexName, mappingName, "_mapping"]
146149 body = Just $ encode mapping
@@ -149,6 +152,7 @@ deleteMapping :: Server -> IndexName -> MappingName -> IO Reply
149152deleteMapping (Server server) (IndexName indexName)
150153 (MappingName mappingName) =
151154 delete $ joinPath [server, indexName, mappingName, "_mapping"]
155+
152156indexDocument :: ToJSON doc => Server -> IndexName -> MappingName
153157 -> doc -> DocId -> IO Reply
154158indexDocument (Server server) (IndexName indexName)
Database/Bloodhound/Types.hs+5−1
@@ -186,7 +186,7 @@ data IndexSettings =
186186defaultIndexSettings :: IndexSettings
187187defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
188188
189−{-| 'Reply' and 'Method' are type synonyms from 'Network.HTTP.Types.Method' -}
189+{-| 'Reply' and 'Method' are type synonyms from 'Network.HTTP.Types.Method.Method' -}
190190type Reply = Network.HTTP.Client.Response L.ByteString
191191type Method = NHTM.Method
192192
@@ -213,6 +213,10 @@ data MappingField =
213213
214214{-| Support for type reification of 'Mapping's is currently incomplete, for
215215 now the mapping API verbiage expects a 'ToJSON'able blob.
216+
217+ Indexes have mappings, mappings are schemas for the documents contained in the
218+ index. I'd recommend having only one mapping per index, always having a mapping,
219+ and keeping different kinds of documents separated if possible.
216220-}
217221data Mapping = Mapping { typeName :: TypeName
218222 , mappingFields :: [MappingField] } deriving (Eq, Show)
Makefile+1−2
@@ -25,11 +25,10 @@ haddock:
2525 cabal haddock --hoogle --hyperlink-source --html-location='http://hackage.haskell.org/package/bloodhound/docs' --contents-location='http://hackage.haskell.org/package/bloodhound'
2626
2727dist:
28− cabal sdist
28+ cabal sdist
2929
3030# upload:
3131# cabal upload dist/bloodhound-0.1.0.2.tar.gz
32−
3332# cp -R ./dist/doc/html/bloodhound/ bloodhound-0.1.0.2-docs
3433# tar cvzf --format=ustar -f bloodhound-0.1.0.1-docs.tar.gz bloodhound-0.1.0.1-docs
3534# curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' --data-binary '@bloodhound-0.1.0.1-docs.tar.gz' 'https://bitemyapp:$PASSWORD@hackage.haskell.org/package/bloodhound-0.1.0.1/docs'
README.org+1−1
@@ -144,7 +144,7 @@ instance ToJSON TweetMapping where
144144 object ["type" .= ("geo_point" :: Text)]]]]
145145:}
146146
147−resp <- createMapping testServer testIndex testMapping TweetMapping
147+resp <- putMapping testServer testIndex testMapping TweetMapping
148148
149149#+END_SRC
150150
tests/tests.hs+1−1
@@ -75,7 +75,7 @@ insertData :: IO ()
7575insertData = do
7676 _ <- deleteExampleIndex
7777 _ <- createExampleIndex
78− _ <- createMapping testServer testIndex testMapping TweetMapping
78+ _ <- putMapping testServer testIndex testMapping TweetMapping
7979 _ <- indexDocument testServer testIndex testMapping exampleTweet (DocId "1")
8080 _ <- refreshIndex testServer testIndex
8181 return ()