-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(QueryDSL): Defined all InputTypes for search.body
- Loading branch information
Showing
39 changed files
with
1,376 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getQueryITC } from '../Query'; | ||
import { getTypeName, getOrSetType, desc } from "../../../utils"; | ||
|
||
export function getBoostingITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryBoosting', opts); | ||
const description = desc(` | ||
The boosting query can be used to effectively demote results that match a given query. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html) | ||
`); | ||
|
||
return getOrSetType(name, () => | ||
// $FlowFixMe | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: { | ||
positive: () => getQueryITC(opts), | ||
negative: () => getQueryITC(opts), | ||
negative_boost: 'Float', | ||
}, | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getQueryITC } from '../Query'; | ||
import { getTypeName, getOrSetType, desc } from "../../../utils"; | ||
|
||
export function getConstantScoreITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryConstantScore', opts); | ||
const description = desc(` | ||
A query that wraps another query and simply returns a constant score equal | ||
to the query boost for every document in the filter. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html) | ||
`); | ||
|
||
return getOrSetType(name, () => | ||
// $FlowFixMe | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: { | ||
filter: () => getQueryITC(opts).getTypeAsRequired(), | ||
boost: 'Float!', | ||
}, | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getQueryITC } from '../Query'; | ||
import { getTypeName, getOrSetType, desc } from "../../../utils"; | ||
|
||
export function getDisMaxITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryDisMax', opts); | ||
const description = desc(` | ||
A query that generates the union of documents produced by its subqueries, | ||
and that scores each document with the maximum score for that document | ||
as produced by any subquery, plus a tie breaking increment | ||
for any additional matching subqueries. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html) | ||
`); | ||
|
||
return getOrSetType(name, () => | ||
// $FlowFixMe | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: { | ||
queries: () => [getQueryITC(opts)], | ||
boost: 'Float', | ||
tie_breaker: 'Float', | ||
}, | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getQueryITC } from '../Query'; | ||
import { getTypeName, getOrSetType, desc } from "../../../utils"; | ||
|
||
export function getFunctionScoreITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryFunctionScore', opts); | ||
const description = desc(` | ||
The function_score allows you to modify the score of documents that | ||
are retrieved by a query. This can be useful if, for example, | ||
a score function is computationally expensive and it is sufficient | ||
to compute the score on a filtered set of documents. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html) | ||
`); | ||
|
||
// $FlowFixMe | ||
const RandomScoreType = InputTypeComposer.create({ | ||
name: getTypeName('QueryFunctionScoreRandom', opts), | ||
fields: { | ||
seed: 'Float', | ||
}, | ||
}); | ||
|
||
return getOrSetType(name, () => | ||
// $FlowFixMe | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: { | ||
query: () => getQueryITC(opts), | ||
boost: 'String', | ||
boost_mode: { | ||
type: 'String', | ||
description: 'Can be: `multiply`, `replace`, `sum`, `avg`, `max`, `min`.', | ||
}, | ||
random_score: RandomScoreType, | ||
// $FlowFixMe | ||
functions: [InputTypeComposer.create({ | ||
name: getTypeName('QueryFunctionScoreFunction', opts), | ||
fields: { | ||
filter: () => getQueryITC(opts), | ||
random_score: RandomScoreType, | ||
weight: 'Float', | ||
script_score: 'JSON', | ||
field_value_factor: 'JSON', | ||
gauss: 'JSON', | ||
linear: 'JSON', | ||
exp: 'JSON', | ||
}, | ||
})], | ||
max_boost: 'Float', | ||
score_mode: { | ||
type: 'String', | ||
description: 'Can be: `multiply`, `sum`, `avg`, `first`, `max`, `min`.', | ||
}, | ||
min_score: 'Float', | ||
}, | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getTypeName, getOrSetType, desc } from '../../../utils'; | ||
|
||
export function getCommonITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryCommon', opts); | ||
const description = desc(` | ||
The common terms query is a modern alternative to stopwords which improves | ||
the precision and recall of search results (by taking stopwords into account), | ||
without sacrificing performance. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html) | ||
`); | ||
|
||
if (false) { | ||
return getOrSetType(name, () => | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: {}, | ||
})); | ||
} | ||
|
||
// $FlowFixMe | ||
return { | ||
type: 'JSON', | ||
description, | ||
}; | ||
} |
4 changes: 2 additions & 2 deletions
4
src/ElasticDSL/Query/Match.js → src/ElasticDSL/Query/FullText/Match.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getTypeName, getOrSetType, desc } from '../../../utils'; | ||
|
||
export function getMatchPhraseITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryMatchPhrase', opts); | ||
const description = desc(` | ||
The match_phrase query analyzes the text and creates a phrase query out | ||
of the analyzed text. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html) | ||
`); | ||
|
||
if (false) { | ||
return getOrSetType(name, () => | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: {}, | ||
})); | ||
} | ||
|
||
// $FlowFixMe | ||
return { | ||
type: 'JSON', | ||
description, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getTypeName, getOrSetType, desc } from '../../../utils'; | ||
|
||
export function getMatchPhrasePrefixITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryMatchPhrasePrefix', opts); | ||
const description = desc(` | ||
The match_phrase_prefix is the same as match_phrase, except that it allows | ||
for prefix matches on the last term in the text. Eg "quick brown f" | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html) | ||
`); | ||
|
||
if (false) { | ||
return getOrSetType(name, () => | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: {}, | ||
})); | ||
} | ||
|
||
// $FlowFixMe | ||
return { | ||
type: 'JSON', | ||
description, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getTypeName, getOrSetType, desc } from '../../../utils'; | ||
|
||
export function getMultiMatchITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryMultiMatch', opts); | ||
const description = desc(` | ||
The multi_match query builds on the match query to allow multi-field queries. | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) | ||
`); | ||
|
||
return getOrSetType(name, () => | ||
// $FlowFixMe | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: { | ||
query: 'String!', | ||
fields: { | ||
type: '[String]!', | ||
description: desc(` | ||
Array of fields [ "title", "*_name", "subject^3" ]. | ||
You may use wildcards and boosting field. | ||
`), | ||
}, | ||
type: `enum ${getTypeName('QueryMultiMatchTypeEnum', opts)} { | ||
best_fields | ||
most_fields | ||
cross_fields | ||
phrase | ||
phrase_prefix | ||
}`, | ||
operator: `enum ${getTypeName('QueryMultiMatchOperatorEnum', opts)} { | ||
and | ||
or | ||
}`, | ||
minimum_should_match: 'String', | ||
analyzer: 'String', | ||
}, | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* @flow */ | ||
|
||
import { InputTypeComposer } from 'graphql-compose'; | ||
import { getTypeName, getOrSetType, desc } from '../../../utils'; | ||
|
||
export function getQueryStringITC(opts: mixed = {}): InputTypeComposer { | ||
const name = getTypeName('QueryQueryString', opts); | ||
const description = desc(` | ||
A query that uses a query parser in order to parse its content. | ||
Eg. "this AND that OR thus" or "(content:this OR name:this) AND (content:that OR name:that)" | ||
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html) | ||
`); | ||
|
||
return getOrSetType(name, () => | ||
// $FlowFixMe | ||
InputTypeComposer.create({ | ||
name, | ||
description, | ||
fields: { | ||
query: 'String!', | ||
fields: '[String]', | ||
default_field: 'String', | ||
default_operator: `enum ${getTypeName('QueryQueryStringOperatorEnum', opts)} { | ||
and | ||
or | ||
}`, | ||
analyzer: 'String', | ||
allow_leading_wildcard: 'Boolean', | ||
enable_position_increments: 'Boolean', | ||
fuzzy_max_expansions: 'Int', | ||
fuzziness: 'String', | ||
fuzzy_prefix_length: 'Int', | ||
phrase_slop: 'Int', | ||
boost: 'Float', | ||
auto_generate_phrase_queries: 'Boolean', | ||
analyze_wildcard: 'Boolean', | ||
max_determinized_states: 'Int', | ||
minimum_should_match: 'String', | ||
lenient: 'Boolean', | ||
time_zone: 'String', | ||
quote_field_suffix: 'String', | ||
split_on_whitespace: 'Boolean', | ||
use_dis_max: 'Boolean', | ||
tie_breaker: 'Int', | ||
}, | ||
})); | ||
} |
Oops, something went wrong.