@@ -1,6 +1,11 @@
11{-# LANGUAGE DeriveGeneric #-}
22
3−{-| Data types for describing actions and data structures performed to interact with Elasticsearch. The two main buckets your queries against Elasticsearch will fall into are 'Query's and 'Filter's. 'Filter's are more like traditional database constraints and often have preferable performance properties. 'Query's support human-written textual queries, such as fuzzy queries.
3+{-| Data types for describing actions and data structures performed to interact
4+ with Elasticsearch. The two main buckets your queries against Elasticsearch
5+ will fall into are 'Query's and 'Filter's. 'Filter's are more like
6+ traditional database constraints and often have preferable performance
7+ properties. 'Query's support human-written textual queries, such as fuzzy
8+ queries.
49-}
510
611module Database.Bloodhound.Types
@@ -153,8 +158,8 @@ data Version = Version { number :: Text
153158 , build_snapshot :: Bool
154159 , lucene_version :: Text } deriving (Eq, Show, Generic)
155160
156−{-| 'Status' is a data type for describing the JSON body returned by Elasticsearch when you
157− query its status. This was deprecated in 1.2.0.
161+{-| 'Status' is a data type for describing the JSON body returned by
162+ Elasticsearch when you query its status. This was deprecated in 1.2.0.
158163
159164 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html#indices-status>
160165-}
@@ -177,7 +182,7 @@ data IndexSettings =
177182
178183{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
179184defaultIndexSettings :: IndexSettings
180−defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
185+defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
181186
182187{-| 'Reply' and 'Method' are type synonyms from 'Network.HTTP.Types.Method' -}
183188type Reply = Network.HTTP.Client.Response L.ByteString
@@ -204,13 +209,15 @@ data MappingField =
204209 MappingField { mappingFieldName :: FieldName
205210 , fieldDefinition :: FieldDefinition } deriving (Eq, Show)
206211
207−{-| Support for type reification of 'Mapping's is currently incomplete, for now the mapping API verbiage expects a 'ToJSON'able blob. -}
212+{-| Support for type reification of 'Mapping's is currently incomplete, for
213+ now the mapping API verbiage expects a 'ToJSON'able blob.
214+-}
208215data Mapping = Mapping { typeName :: TypeName
209216 , mappingFields :: [MappingField] } deriving (Eq, Show)
210217
211−{-| 'BulkOperation' is a sum type for expressing the four kinds of bulk operation index,
212− create, delete, and update. 'BulkIndex' behaves like an "upsert", 'BulkCreate' will fail
213− if a document already exists at the DocId.
218+{-| 'BulkOperation' is a sum type for expressing the four kinds of bulk
219+ operation index, create, delete, and update. 'BulkIndex' behaves like an
220+ "upsert", 'BulkCreate' will fail if a document already exists at the DocId.
214221
215222 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html#docs-bulk>
216223-}
@@ -220,7 +227,8 @@ data BulkOperation =
220227 | BulkDelete IndexName MappingName DocId
221228 | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Show)
222229
223−{-| 'EsResult' describes the standard wrapper JSON document that you see in successful Elasticsearch responses.
230+{-| 'EsResult' describes the standard wrapper JSON document that you see in
231+ successful Elasticsearch responses.
224232-}
225233data EsResult a = EsResult { _index :: Text
226234 , _type :: Text
@@ -229,19 +237,24 @@ data EsResult a = EsResult { _index :: Text
229237 , found :: Maybe Bool
230238 , _source :: a } deriving (Eq, Show)
231239
232−{-| 'Sort' is a synonym for a list of 'SortSpec's. Sort behavior is order dependent with later sorts acting as tie-breakers for earlier sorts.
240+{-| 'Sort' is a synonym for a list of 'SortSpec's. Sort behavior is order
241+ dependent with later sorts acting as tie-breakers for earlier sorts.
233242-}
234243type Sort = [SortSpec]
235244
236−{-| The two main kinds of 'SortSpec' are 'DefaultSortSpec' and 'GeoDistanceSortSpec'. The latter takes a 'SortOrder', 'GeoPoint', and 'DistanceUnit' to express "nearness" to a single geographical point as a sort specification.
245+{-| The two main kinds of 'SortSpec' are 'DefaultSortSpec' and
246+ 'GeoDistanceSortSpec'. The latter takes a 'SortOrder', 'GeoPoint', and
247+ 'DistanceUnit' to express "nearness" to a single geographical point as a
248+ sort specification.
237249
238250<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
239251-}
240252data SortSpec = DefaultSortSpec DefaultSort
241253 | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Show)
242254
243−{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a 'mkSort' convenience
244− function for when you want to specify only the most common parameters.
255+{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
256+ 'mkSort' convenience function for when you want to specify only the most
257+ common parameters.
245258
246259<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
247260-}
@@ -254,14 +267,16 @@ data DefaultSort =
254267 , missingSort :: Maybe Missing
255268 , nestedFilter :: Maybe Filter } deriving (Eq, Show)
256269
257−{-| 'SortOrder' is 'Ascending' or 'Descending', as you might expect. These get encoded into "asc" or "desc" when turned into JSON.
270+{-| 'SortOrder' is 'Ascending' or 'Descending', as you might expect. These get
271+ encoded into "asc" or "desc" when turned into JSON.
258272
259273<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
260274-}
261275data SortOrder = Ascending
262276 | Descending deriving (Eq, Show)
263277
264−{-| 'Missing' prescribes how to handle missing fields. A missing field can be sorted last, first, or using a custom value as a substitute.
278+{-| 'Missing' prescribes how to handle missing fields. A missing field can be
279+ sorted last, first, or using a custom value as a substitute.
265280
266281<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_missing_values>
267282-}
@@ -278,7 +293,8 @@ data SortMode = SortMin
278293 | SortSum
279294 | SortAvg deriving (Eq, Show)
280295
281−{-| 'mkSort' defaults everything but the 'FieldName' and the 'SortOrder' so that you can concisely describe the usual kind of 'SortSpec's you want.
296+{-| 'mkSort' defaults everything but the 'FieldName' and the 'SortOrder' so
297+ that you can concisely describe the usual kind of 'SortSpec's you want.
282298-}
283299mkSort :: FieldName -> SortOrder -> DefaultSort
284300mkSort fieldName sOrder = DefaultSort fieldName sOrder False Nothing Nothing Nothing
@@ -290,7 +306,8 @@ type Cache = Bool -- caching on/off
290306defaultCache :: Cache
291307defaultCache = False
292308
293−{-| 'PrefixValue' is used in 'PrefixQuery' as the main query component. -}
309+{-| 'PrefixValue' is used in 'PrefixQuery' as the main query component.
310+-}
294311type PrefixValue = Text
295312
296313{-| 'BooleanOperator' is the usual And/Or operators with an ES compatible
@@ -298,79 +315,143 @@ type PrefixValue = Text
298315-}
299316data BooleanOperator = And | Or deriving (Eq, Show)
300317
301−{-| 'ShardCount' is part of 'IndexSettings' -}
302−newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic)
303−{-| 'ReplicaCount' is part of 'IndexSettings' -}
304−newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic)
305−{-| 'Server' is used with the client functions to point at the ES instance -}
306−newtype Server = Server String deriving (Eq, Show)
307−{-| 'IndexName' is used to describe which index to query/create/delete -}
308−newtype IndexName = IndexName String deriving (Eq, Generic, Show)
318+{-| 'ShardCount' is part of 'IndexSettings'
319+-}
320+newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic)
321+
322+{-| 'ReplicaCount' is part of 'IndexSettings'
323+-}
324+newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic)
325+
326+{-| 'Server' is used with the client functions to point at the ES instance
327+-}
328+newtype Server = Server String deriving (Eq, Show)
329+
330+{-| 'IndexName' is used to describe which index to query/create/delete
331+-}
332+newtype IndexName = IndexName String deriving (Eq, Generic, Show)
333+
309334{-| 'MappingName' is part of mappings which are how ES describes and schematizes
310− the data in the indices. -}
311−newtype MappingName = MappingName String deriving (Eq, Generic, Show)
312−{-| 'DocId' is a generic wrapper value for expressing unique Document IDs. Can be set
313− by the user or created by ES itself. Often used in client functions for poking
314− at specific documents. -}
315−newtype DocId = DocId String deriving (Eq, Generic, Show)
316−{-| 'QueryString' is used to wrap query text bodies, be they human written or not. -}
317−newtype QueryString = QueryString Text deriving (Eq, Generic, Show)
335+ the data in the indices.
336+-}
337+newtype MappingName = MappingName String deriving (Eq, Generic, Show)
338+
339+{-| 'DocId' is a generic wrapper value for expressing unique Document IDs.
340+ Can be set by the user or created by ES itself. Often used in client
341+ functions for poking at specific documents.
342+-}
343+newtype DocId = DocId String deriving (Eq, Generic, Show)
344+
345+{-| 'QueryString' is used to wrap query text bodies, be they human written or not.
346+-}
347+newtype QueryString = QueryString Text deriving (Eq, Generic, Show)
348+
318349{-| 'FieldName' is used all over the place wherever a specific field within
319− a document needs to be specified, usually in 'Query's or 'Filter's. -}
320−newtype FieldName = FieldName Text deriving (Eq, Show)
350+ a document needs to be specified, usually in 'Query's or 'Filter's.
351+-}
352+newtype FieldName = FieldName Text deriving (Eq, Show)
353+
321354{-| 'CacheName' is used in 'RegexpQuery' and 'RegexpFilter' for describing the
322− 'CacheKey' keyed caching behavior. -}
323−newtype CacheName = CacheName Text deriving (Eq, Show)
355+ 'CacheKey' keyed caching behavior.
356+-}
357+newtype CacheName = CacheName Text deriving (Eq, Show)
358+
324359{-| 'CacheKey' is used in 'RegexpQuery' and 'RegexpFilter' to key regex
325− caching behavior. -}
326−newtype CacheKey = CacheKey Text deriving (Eq, Show)
327−newtype Existence = Existence Bool deriving (Eq, Show)
328−newtype NullValue = NullValue Bool deriving (Eq, Show)
329−newtype CutoffFrequency = CutoffFrequency Double deriving (Eq, Show, Generic)
330−newtype Analyzer = Analyzer Text deriving (Eq, Show, Generic)
331−newtype MaxExpansions = MaxExpansions Int deriving (Eq, Show, Generic)
360+ caching behavior.
361+-}
362+newtype CacheKey =
363+ CacheKey Text deriving (Eq, Show)
364+newtype Existence =
365+ Existence Bool deriving (Eq, Show)
366+newtype NullValue =
367+ NullValue Bool deriving (Eq, Show)
368+newtype CutoffFrequency =
369+ CutoffFrequency Double deriving (Eq, Show, Generic)
370+newtype Analyzer =
371+ Analyzer Text deriving (Eq, Show, Generic)
372+newtype MaxExpansions =
373+ MaxExpansions Int deriving (Eq, Show, Generic)
374+
332375{-| 'Lenient', if set to true, will cause format based failures to be
333376 ignored. I don't know what the bloody default is, Elasticsearch
334− documentation didn't say what it was. Let me know if you figure it out. -}
335−newtype Lenient = Lenient Bool deriving (Eq, Show, Generic)
336−newtype Tiebreaker = Tiebreaker Double deriving (Eq, Show, Generic)
337−newtype Boost = Boost Double deriving (Eq, Show, Generic)
338−newtype BoostTerms = BoostTerms Double deriving (Eq, Show, Generic)
339−{-| 'MinimumMatch' controls how many should clauses in the bool query should match.
340− Can be an absolute value (2) or a percentage (30%) or a combination of both. -}
341−newtype MinimumMatch = MinimumMatch Int deriving (Eq, Show, Generic)
342−newtype MinimumMatchText = MinimumMatchText Text deriving (Eq, Show)
343−newtype DisableCoord = DisableCoord Bool deriving (Eq, Show, Generic)
344−newtype IgnoreTermFrequency = IgnoreTermFrequency Bool deriving (Eq, Show, Generic)
345−newtype MinimumTermFrequency = MinimumTermFrequency Int deriving (Eq, Show, Generic)
346−newtype MaxQueryTerms = MaxQueryTerms Int deriving (Eq, Show, Generic)
347−newtype Fuzziness = Fuzziness Double deriving (Eq, Show, Generic)
377+ documentation didn't say what it was. Let me know if you figure it out.
378+-}
379+newtype Lenient =
380+ Lenient Bool deriving (Eq, Show, Generic)
381+newtype Tiebreaker =
382+ Tiebreaker Double deriving (Eq, Show, Generic)
383+newtype Boost =
384+ Boost Double deriving (Eq, Show, Generic)
385+newtype BoostTerms =
386+ BoostTerms Double deriving (Eq, Show, Generic)
387+
388+{-| 'MinimumMatch' controls how many should clauses in the bool query should
389+ match. Can be an absolute value (2) or a percentage (30%) or a
390+ combination of both.
391+-}
392+newtype MinimumMatch =
393+ MinimumMatch Int deriving (Eq, Show, Generic)
394+newtype MinimumMatchText =
395+ MinimumMatchText Text deriving (Eq, Show)
396+newtype DisableCoord =
397+ DisableCoord Bool deriving (Eq, Show, Generic)
398+newtype IgnoreTermFrequency =
399+ IgnoreTermFrequency Bool deriving (Eq, Show, Generic)
400+newtype MinimumTermFrequency =
401+ MinimumTermFrequency Int deriving (Eq, Show, Generic)
402+newtype MaxQueryTerms =
403+ MaxQueryTerms Int deriving (Eq, Show, Generic)
404+newtype Fuzziness =
405+ Fuzziness Double deriving (Eq, Show, Generic)
406+
348407{-| 'PrefixLength' is the prefix length used in queries, defaults to 0. -}
349−newtype PrefixLength = PrefixLength Int deriving (Eq, Show, Generic)
350−newtype TypeName = TypeName Text deriving (Eq, Show, Generic)
351−newtype PercentMatch = PercentMatch Double deriving (Eq, Show, Generic)
352−newtype StopWord = StopWord Text deriving (Eq, Show, Generic)
353−newtype QueryPath = QueryPath Text deriving (Eq, Show, Generic)
354−{-| Allowing a wildcard at the beginning of a word (eg "*ing") is particularly heavy, because all terms in the index need to be examined, just in case they match. Leading wildcards can be disabled by setting 'AllowLeadingWildcard' to false. -}
355−newtype AllowLeadingWildcard = AllowLeadingWildcard Bool deriving (Eq, Show, Generic)
356−newtype LowercaseExpanded = LowercaseExpanded Bool deriving (Eq, Show, Generic)
357−newtype EnablePositionIncrements = EnablePositionIncrements Bool deriving (Eq, Show, Generic)
408+newtype PrefixLength =
409+ PrefixLength Int deriving (Eq, Show, Generic)
410+newtype TypeName =
411+ TypeName Text deriving (Eq, Show, Generic)
412+newtype PercentMatch =
413+ PercentMatch Double deriving (Eq, Show, Generic)
414+newtype StopWord =
415+ StopWord Text deriving (Eq, Show, Generic)
416+newtype QueryPath =
417+ QueryPath Text deriving (Eq, Show, Generic)
418+
419+{-| Allowing a wildcard at the beginning of a word (eg "*ing") is particularly
420+ heavy, because all terms in the index need to be examined, just in case
421+ they match. Leading wildcards can be disabled by setting
422+ 'AllowLeadingWildcard' to false. -}
423+newtype AllowLeadingWildcard =
424+ AllowLeadingWildcard Bool deriving (Eq, Show, Generic)
425+newtype LowercaseExpanded =
426+ LowercaseExpanded Bool deriving (Eq, Show, Generic)
427+newtype EnablePositionIncrements =
428+ EnablePositionIncrements Bool deriving (Eq, Show, Generic)
429+
358430{-| By default, wildcard terms in a query are not analyzed.
359− Setting 'AnalyzeWildcard' to true enables best-effort analysis. -}
360−newtype AnalyzeWildcard = AnalyzeWildcard Bool deriving (Eq, Show, Generic)
361−{-| 'GeneratePhraseQueries' defaults to false. -}
362−newtype GeneratePhraseQueries = GeneratePhraseQueries Bool deriving (Eq, Show, Generic)
363−{-| 'Locale' is used for string conversions - defaults to ROOT. -}
364−newtype Locale = Locale Text deriving (Eq, Show, Generic)
365−newtype MaxWordLength = MaxWordLength Int deriving (Eq, Show, Generic)
366−newtype MinWordLength = MinWordLength Int deriving (Eq, Show, Generic)
431+ Setting 'AnalyzeWildcard' to true enables best-effort analysis.
432+-}
433+newtype AnalyzeWildcard = AnalyzeWildcard Bool deriving (Eq, Show, Generic)
434+
435+{-| 'GeneratePhraseQueries' defaults to false.
436+-}
437+newtype GeneratePhraseQueries =
438+ GeneratePhraseQueries Bool deriving (Eq, Show, Generic)
439+
440+{-| 'Locale' is used for string conversions - defaults to ROOT.
441+-}
442+newtype Locale = Locale Text deriving (Eq, Show, Generic)
443+newtype MaxWordLength = MaxWordLength Int deriving (Eq, Show, Generic)
444+newtype MinWordLength = MinWordLength Int deriving (Eq, Show, Generic)
445+
367446{-| 'PhraseSlop' sets the default slop for phrases, 0 means exact
368− phrase matches. Default is 0. -}
369−newtype PhraseSlop = PhraseSlop Int deriving (Eq, Show, Generic)
370−newtype MinDocFrequency = MinDocFrequency Int deriving (Eq, Show, Generic)
371−newtype MaxDocFrequency = MaxDocFrequency Int deriving (Eq, Show, Generic)
447+ phrase matches. Default is 0.
448+-}
449+newtype PhraseSlop = PhraseSlop Int deriving (Eq, Show, Generic)
450+newtype MinDocFrequency = MinDocFrequency Int deriving (Eq, Show, Generic)
451+newtype MaxDocFrequency = MaxDocFrequency Int deriving (Eq, Show, Generic)
372452
373−{-| 'unpackId' is a silly convenience function that gets used once. -}
453+{-| 'unpackId' is a silly convenience function that gets used once.
454+-}
374455unpackId :: DocId -> String
375456unpackId (DocId docId) = docId
376457
@@ -433,14 +514,15 @@ mkRangeQuery :: FieldName -> Either HalfRange Range -> RangeQuery
433514mkRangeQuery f r = RangeQuery f r (Boost 1.0)
434515
435516data SimpleQueryStringQuery =
436− SimpleQueryStringQuery { simpleQueryStringQuery :: QueryString
437− , simpleQueryStringField :: Maybe FieldOrFields
438− , simpleQueryStringOperator :: Maybe BooleanOperator
439− , simpleQueryStringAnalyzer :: Maybe Analyzer
440− , simpleQueryStringFlags :: Maybe [SimpleQueryFlag]
441− , simpleQueryStringLowercaseExpanded :: Maybe LowercaseExpanded
442− , simpleQueryStringLocale :: Maybe Locale
443− } deriving (Eq, Show)
517+ SimpleQueryStringQuery
518+ { simpleQueryStringQuery :: QueryString
519+ , simpleQueryStringField :: Maybe FieldOrFields
520+ , simpleQueryStringOperator :: Maybe BooleanOperator
521+ , simpleQueryStringAnalyzer :: Maybe Analyzer
522+ , simpleQueryStringFlags :: Maybe [SimpleQueryFlag]
523+ , simpleQueryStringLowercaseExpanded :: Maybe LowercaseExpanded
524+ , simpleQueryStringLocale :: Maybe Locale
525+ } deriving (Eq, Show)
444526
445527data SimpleQueryFlag =
446528 SimpleQueryAll
@@ -458,141 +540,156 @@ data SimpleQueryFlag =
458540
459541-- use_dis_max and tie_breaker when fields are plural?
460542data QueryStringQuery =
461− QueryStringQuery { queryStringQuery :: QueryString
462− , queryStringDefaultField :: Maybe FieldName
463− , queryStringOperator :: Maybe BooleanOperator
464− , queryStringAnalyzer :: Maybe Analyzer
465− , queryStringAllowLeadingWildcard :: Maybe AllowLeadingWildcard
466− , queryStringLowercaseExpanded :: Maybe LowercaseExpanded
467− , queryStringEnablePositionIncrements :: Maybe EnablePositionIncrements
468− , queryStringFuzzyMaxExpansions :: Maybe MaxExpansions
469− , queryStringFuzziness :: Maybe Fuzziness
470− , queryStringFuzzyPrefixLength :: Maybe PrefixLength
471− , queryStringPhraseSlop :: Maybe PhraseSlop
472− , queryStringBoost :: Maybe Boost
473− , queryStringAnalyzeWildcard :: Maybe AnalyzeWildcard
474− , queryStringGeneratePhraseQueries :: Maybe GeneratePhraseQueries
475− , queryStringMinimumShouldMatch :: Maybe MinimumMatch
476− , queryStringLenient :: Maybe Lenient
477− , queryStringLocale :: Maybe Locale
478− } deriving (Eq, Show)
543+ QueryStringQuery
544+ { queryStringQuery :: QueryString
545+ , queryStringDefaultField :: Maybe FieldName
546+ , queryStringOperator :: Maybe BooleanOperator
547+ , queryStringAnalyzer :: Maybe Analyzer
548+ , queryStringAllowLeadingWildcard :: Maybe AllowLeadingWildcard
549+ , queryStringLowercaseExpanded :: Maybe LowercaseExpanded
550+ , queryStringEnablePositionIncrements :: Maybe EnablePositionIncrements
551+ , queryStringFuzzyMaxExpansions :: Maybe MaxExpansions
552+ , queryStringFuzziness :: Maybe Fuzziness
553+ , queryStringFuzzyPrefixLength :: Maybe PrefixLength
554+ , queryStringPhraseSlop :: Maybe PhraseSlop
555+ , queryStringBoost :: Maybe Boost
556+ , queryStringAnalyzeWildcard :: Maybe AnalyzeWildcard
557+ , queryStringGeneratePhraseQueries :: Maybe GeneratePhraseQueries
558+ , queryStringMinimumShouldMatch :: Maybe MinimumMatch
559+ , queryStringLenient :: Maybe Lenient
560+ , queryStringLocale :: Maybe Locale
561+ } deriving (Eq, Show)
479562
480563mkQueryStringQuery :: QueryString -> QueryStringQuery
481−mkQueryStringQuery qs = QueryStringQuery qs Nothing Nothing
482− Nothing Nothing Nothing Nothing
483− Nothing Nothing Nothing Nothing
484− Nothing Nothing Nothing Nothing
485− Nothing Nothing
486−
487−data FieldOrFields = FofField FieldName
564+mkQueryStringQuery qs =
565+ QueryStringQuery qs Nothing Nothing
566+ Nothing Nothing Nothing Nothing
567+ Nothing Nothing Nothing Nothing
568+ Nothing Nothing Nothing Nothing
569+ Nothing Nothing
570+
571+data FieldOrFields = FofField FieldName
488572 | FofFields [FieldName] deriving (Eq, Show)
489573
490574data PrefixQuery =
491− PrefixQuery { prefixQueryField :: FieldName
492− , prefixQueryPrefixValue :: Text
493− , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show)
575+ PrefixQuery
576+ { prefixQueryField :: FieldName
577+ , prefixQueryPrefixValue :: Text
578+ , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show)
494579
495580data NestedQuery =
496− NestedQuery { nestedQueryPath :: QueryPath
497− , nestedQueryScoreType :: ScoreType
498− , nestedQuery :: Query } deriving (Eq, Show)
581+ NestedQuery
582+ { nestedQueryPath :: QueryPath
583+ , nestedQueryScoreType :: ScoreType
584+ , nestedQuery :: Query } deriving (Eq, Show)
499585
500586data MoreLikeThisFieldQuery =
501− MoreLikeThisFieldQuery { moreLikeThisFieldText :: Text
502− , moreLikeThisFieldFields :: FieldName
503− -- default 0.3 (30%)
504− , moreLikeThisFieldPercentMatch :: Maybe PercentMatch
505− , moreLikeThisFieldMinimumTermFreq :: Maybe MinimumTermFrequency
506− , moreLikeThisFieldMaxQueryTerms :: Maybe MaxQueryTerms
507− , moreLikeThisFieldStopWords :: Maybe [StopWord]
508− , moreLikeThisFieldMinDocFrequency :: Maybe MinDocFrequency
509− , moreLikeThisFieldMaxDocFrequency :: Maybe MaxDocFrequency
510− , moreLikeThisFieldMinWordLength :: Maybe MinWordLength
511− , moreLikeThisFieldMaxWordLength :: Maybe MaxWordLength
512− , moreLikeThisFieldBoostTerms :: Maybe BoostTerms
513− , moreLikeThisFieldBoost :: Maybe Boost
514− , moreLikeThisFieldAnalyzer :: Maybe Analyzer
515− } deriving (Eq, Show)
587+ MoreLikeThisFieldQuery
588+ { moreLikeThisFieldText :: Text
589+ , moreLikeThisFieldFields :: FieldName
590+ -- default 0.3 (30%)
591+ , moreLikeThisFieldPercentMatch :: Maybe PercentMatch
592+ , moreLikeThisFieldMinimumTermFreq :: Maybe MinimumTermFrequency
593+ , moreLikeThisFieldMaxQueryTerms :: Maybe MaxQueryTerms
594+ , moreLikeThisFieldStopWords :: Maybe [StopWord]
595+ , moreLikeThisFieldMinDocFrequency :: Maybe MinDocFrequency
596+ , moreLikeThisFieldMaxDocFrequency :: Maybe MaxDocFrequency
597+ , moreLikeThisFieldMinWordLength :: Maybe MinWordLength
598+ , moreLikeThisFieldMaxWordLength :: Maybe MaxWordLength
599+ , moreLikeThisFieldBoostTerms :: Maybe BoostTerms
600+ , moreLikeThisFieldBoost :: Maybe Boost
601+ , moreLikeThisFieldAnalyzer :: Maybe Analyzer
602+ } deriving (Eq, Show)
516603
517604data MoreLikeThisQuery =
518− MoreLikeThisQuery { moreLikeThisText :: Text
519− , moreLikeThisFields :: Maybe [FieldName]
520− -- default 0.3 (30%)
521− , moreLikeThisPercentMatch :: Maybe PercentMatch
522− , moreLikeThisMinimumTermFreq :: Maybe MinimumTermFrequency
523− , moreLikeThisMaxQueryTerms :: Maybe MaxQueryTerms
524− , moreLikeThisStopWords :: Maybe [StopWord]
525− , moreLikeThisMinDocFrequency :: Maybe MinDocFrequency
526− , moreLikeThisMaxDocFrequency :: Maybe MaxDocFrequency
527− , moreLikeThisMinWordLength :: Maybe MinWordLength
528− , moreLikeThisMaxWordLength :: Maybe MaxWordLength
529− , moreLikeThisBoostTerms :: Maybe BoostTerms
530− , moreLikeThisBoost :: Maybe Boost
531− , moreLikeThisAnalyzer :: Maybe Analyzer
532− } deriving (Eq, Show)
533−
605+ MoreLikeThisQuery
606+ { moreLikeThisText :: Text
607+ , moreLikeThisFields :: Maybe [FieldName]
608+ -- default 0.3 (30%)
609+ , moreLikeThisPercentMatch :: Maybe PercentMatch
610+ , moreLikeThisMinimumTermFreq :: Maybe MinimumTermFrequency
611+ , moreLikeThisMaxQueryTerms :: Maybe MaxQueryTerms
612+ , moreLikeThisStopWords :: Maybe [StopWord]
613+ , moreLikeThisMinDocFrequency :: Maybe MinDocFrequency
614+ , moreLikeThisMaxDocFrequency :: Maybe MaxDocFrequency
615+ , moreLikeThisMinWordLength :: Maybe MinWordLength
616+ , moreLikeThisMaxWordLength :: Maybe MaxWordLength
617+ , moreLikeThisBoostTerms :: Maybe BoostTerms
618+ , moreLikeThisBoost :: Maybe Boost
619+ , moreLikeThisAnalyzer :: Maybe Analyzer
620+ } deriving (Eq, Show)
534621
535622data IndicesQuery =
536− IndicesQuery { indicesQueryIndices :: [IndexName]
537− , indicesQuery :: Query
538− -- default "all"
539− , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show)
623+ IndicesQuery
624+ { indicesQueryIndices :: [IndexName]
625+ , indicesQuery :: Query
626+ -- default "all"
627+ , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show)
540628
541629data HasParentQuery =
542− HasParentQuery { hasParentQueryType :: TypeName
543− , hasParentQuery :: Query
544− , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show)
630+ HasParentQuery
631+ { hasParentQueryType :: TypeName
632+ , hasParentQuery :: Query
633+ , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show)
545634
546635data HasChildQuery =
547− HasChildQuery { hasChildQueryType :: TypeName
548− , hasChildQuery :: Query
549− , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show)
550−
551−data ScoreType = ScoreTypeMax
552− | ScoreTypeSum
553− | ScoreTypeAvg
554− | ScoreTypeNone deriving (Eq, Show)
555−
556−data FuzzyQuery = FuzzyQuery { fuzzyQueryField :: FieldName
557− , fuzzyQueryValue :: Text
558− , fuzzyQueryPrefixLength :: PrefixLength
559− , fuzzyQueryMaxExpansions :: MaxExpansions
560− , fuzzyQueryFuzziness :: Fuzziness
561− , fuzzyQueryBoost :: Maybe Boost
562− } deriving (Eq, Show)
636+ HasChildQuery
637+ { hasChildQueryType :: TypeName
638+ , hasChildQuery :: Query
639+ , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show)
640+
641+data ScoreType =
642+ ScoreTypeMax
643+ | ScoreTypeSum
644+ | ScoreTypeAvg
645+ | ScoreTypeNone deriving (Eq, Show)
646+
647+data FuzzyQuery =
648+ FuzzyQuery { fuzzyQueryField :: FieldName
649+ , fuzzyQueryValue :: Text
650+ , fuzzyQueryPrefixLength :: PrefixLength
651+ , fuzzyQueryMaxExpansions :: MaxExpansions
652+ , fuzzyQueryFuzziness :: Fuzziness
653+ , fuzzyQueryBoost :: Maybe Boost
654+ } deriving (Eq, Show)
563655
564656data FuzzyLikeFieldQuery =
565− FuzzyLikeFieldQuery { fuzzyLikeField :: FieldName
566− -- anaphora is good for the soul.
567− , fuzzyLikeFieldText :: Text
568− , fuzzyLikeFieldMaxQueryTerms :: MaxQueryTerms
569− , fuzzyLikeFieldIgnoreTermFrequency :: IgnoreTermFrequency
570− , fuzzyLikeFieldFuzziness :: Fuzziness
571− , fuzzyLikeFieldPrefixLength :: PrefixLength
572− , fuzzyLikeFieldBoost :: Boost
573− , fuzzyLikeFieldAnalyzer :: Maybe Analyzer
574− } deriving (Eq, Show)
657+ FuzzyLikeFieldQuery
658+ { fuzzyLikeField :: FieldName
659+ -- anaphora is good for the soul.
660+ , fuzzyLikeFieldText :: Text
661+ , fuzzyLikeFieldMaxQueryTerms :: MaxQueryTerms
662+ , fuzzyLikeFieldIgnoreTermFrequency :: IgnoreTermFrequency
663+ , fuzzyLikeFieldFuzziness :: Fuzziness
664+ , fuzzyLikeFieldPrefixLength :: PrefixLength
665+ , fuzzyLikeFieldBoost :: Boost
666+ , fuzzyLikeFieldAnalyzer :: Maybe Analyzer
667+ } deriving (Eq, Show)
575668
576669data FuzzyLikeThisQuery =
577− FuzzyLikeThisQuery { fuzzyLikeFields :: [FieldName]
578− , fuzzyLikeText :: Text
579− , fuzzyLikeMaxQueryTerms :: MaxQueryTerms
580− , fuzzyLikeIgnoreTermFrequency :: IgnoreTermFrequency
581− , fuzzyLikeFuzziness :: Fuzziness
582− , fuzzyLikePrefixLength :: PrefixLength
583− , fuzzyLikeBoost :: Boost
584− , fuzzyLikeAnalyzer :: Maybe Analyzer
585− } deriving (Eq, Show)
670+ FuzzyLikeThisQuery
671+ { fuzzyLikeFields :: [FieldName]
672+ , fuzzyLikeText :: Text
673+ , fuzzyLikeMaxQueryTerms :: MaxQueryTerms
674+ , fuzzyLikeIgnoreTermFrequency :: IgnoreTermFrequency
675+ , fuzzyLikeFuzziness :: Fuzziness
676+ , fuzzyLikePrefixLength :: PrefixLength
677+ , fuzzyLikeBoost :: Boost
678+ , fuzzyLikeAnalyzer :: Maybe Analyzer
679+ } deriving (Eq, Show)
586680
587681data FilteredQuery =
588− FilteredQuery { filteredQuery :: Query
589− , filteredFilter :: Filter } deriving (Eq, Show)
590−
591−data DisMaxQuery = DisMaxQuery { disMaxQueries :: [Query]
592− -- default 0.0
593− , disMaxTiebreaker :: Tiebreaker
594− , disMaxBoost :: Maybe Boost
595− } deriving (Eq, Show)
682+ FilteredQuery
683+ { filteredQuery :: Query
684+ , filteredFilter :: Filter } deriving (Eq, Show)
685+
686+data DisMaxQuery =
687+ DisMaxQuery { disMaxQueries :: [Query]
688+ -- default 0.0
689+ , disMaxTiebreaker :: Tiebreaker
690+ , disMaxBoost :: Maybe Boost
691+ } deriving (Eq, Show)
692+
596693data MatchQuery =
597694 MatchQuery { matchQueryField :: FieldName
598695 , matchQueryQueryString :: QueryString
@@ -610,8 +707,9 @@ data MatchQuery =
610707mkMatchQuery :: FieldName -> QueryString -> MatchQuery
611708mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing
612709
613−data MatchQueryType = MatchPhrase
614− | MatchPhrasePrefix deriving (Eq, Show)
710+data MatchQueryType =
711+ MatchPhrase
712+ | MatchPhrasePrefix deriving (Eq, Show)
615713
616714data MultiMatchQuery =
617715 MultiMatchQuery { multiMatchQueryFields :: [FieldName]
@@ -632,28 +730,33 @@ data MultiMatchQuery =
632730
633731mkMultiMatchQuery :: [FieldName] -> QueryString -> MultiMatchQuery
634732mkMultiMatchQuery matchFields query =
635− MultiMatchQuery matchFields query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing
636−
637−data MultiMatchQueryType = MultiMatchBestFields
638− | MultiMatchMostFields
639− | MultiMatchCrossFields
640− | MultiMatchPhrase
641− | MultiMatchPhrasePrefix deriving (Eq, Show)
642−
643−data BoolQuery = BoolQuery { boolQueryMustMatch :: Maybe Query
644− , boolQueryMustNotMatch :: Maybe Query
645− , boolQueryShouldMatch :: Maybe [Query]
646− , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
647− , boolQueryBoost :: Maybe Boost
648− , boolQueryDisableCoord :: Maybe DisableCoord
649− } deriving (Eq, Show)
733+ MultiMatchQuery matchFields query
734+ Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing
735+
736+data MultiMatchQueryType =
737+ MultiMatchBestFields
738+ | MultiMatchMostFields
739+ | MultiMatchCrossFields
740+ | MultiMatchPhrase
741+ | MultiMatchPhrasePrefix deriving (Eq, Show)
742+
743+data BoolQuery =
744+ BoolQuery { boolQueryMustMatch :: Maybe Query
745+ , boolQueryMustNotMatch :: Maybe Query
746+ , boolQueryShouldMatch :: Maybe [Query]
747+ , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
748+ , boolQueryBoost :: Maybe Boost
749+ , boolQueryDisableCoord :: Maybe DisableCoord
750+ } deriving (Eq, Show)
650751
651752mkBoolQuery :: Maybe Query -> Maybe Query -> Maybe [Query] -> BoolQuery
652−mkBoolQuery must mustNot should = BoolQuery must mustNot should Nothing Nothing Nothing
753+mkBoolQuery must mustNot should =
754+ BoolQuery must mustNot should Nothing Nothing Nothing
653755
654−data BoostingQuery = BoostingQuery { positiveQuery :: Query
655− , negativeQuery :: Query
656− , negativeBoost :: Boost } deriving (Eq, Show)
756+data BoostingQuery =
757+ BoostingQuery { positiveQuery :: Query
758+ , negativeQuery :: Query
759+ , negativeBoost :: Boost } deriving (Eq, Show)
657760
658761data CommonTermsQuery =
659762 CommonTermsQuery { commonField :: FieldName
@@ -667,9 +770,10 @@ data CommonTermsQuery =
667770 , commonDisableCoord :: Maybe DisableCoord
668771 } deriving (Eq, Show)
669772
670−data CommonMinimumMatch = CommonMinimumMatchHighLow MinimumMatchHighLow
671− | CommonMinimumMatch MinimumMatch
672− deriving (Eq, Show)
773+data CommonMinimumMatch =
774+ CommonMinimumMatchHighLow MinimumMatchHighLow
775+ | CommonMinimumMatch MinimumMatch
776+ deriving (Eq, Show)
673777
674778data MinimumMatchHighLow =
675779 MinimumMatchHighLow { lowFreq :: MinimumMatch
@@ -725,9 +829,9 @@ halfRangeToKV (HalfRangeGt (GreaterThan n)) = ("gt", n)
725829halfRangeToKV (HalfRangeGte (GreaterThanEq n)) = ("gte", n)
726830
727831rangeToKV :: Range -> (Text, Double, Text, Double)
728−rangeToKV (RangeLtGt (LessThan m) (GreaterThan n)) = ("lt", m, "gt", n)
832+rangeToKV (RangeLtGt (LessThan m) (GreaterThan n)) = ("lt", m, "gt", n)
729833rangeToKV (RangeLtGte (LessThan m) (GreaterThanEq n)) = ("lt", m, "gte", n)
730−rangeToKV (RangeLteGt (LessThanEq m) (GreaterThan n)) = ("lte", m, "gt", n)
834+rangeToKV (RangeLteGt (LessThanEq m) (GreaterThan n)) = ("lte", m, "gt", n)
731835rangeToKV (RangeLteGte (LessThanEq m) (GreaterThanEq n)) = ("lte", m, "gte", n)
732836
733837-- phew. Coulda used Agda style case breaking there but, you know, whatever. :)
@@ -743,7 +847,6 @@ data BoolMatch = MustMatch Term Cache
743847data GeoFilterType = GeoFilterMemory
744848 | GeoFilterIndexed deriving (Eq, Show)
745849
746−
747850data LatLon = LatLon { lat :: Double
748851 , lon :: Double } deriving (Eq, Show)
749852