Skip to content

Commit 7fda6b8

Browse files
authored
refact(answers): answers query implements SearchParameters (#238)
1 parent 3005d49 commit 7fda6b8

File tree

15 files changed

+1375
-140
lines changed

15 files changed

+1375
-140
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 1.6.1
22

3+
### Added
4+
- Settings: `attributeCriteriaComputedByMinProximity` parameter
5+
- AnswersQuery: implements `SearchParameters` for convenience (delegated to `params`)
6+
37
### Fixed
48
- Experimental annotation KDoc
59
- RankingInfo: personalization fields deserialization
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.algolia.search.model.params
2+
3+
public interface AnswersParameters : CommonSearchParameters {
4+
5+
/**
6+
* The query for which to retrieve results. Cannot be empty or spaces only.
7+
* [Documentation][https://www.algolia.com/doc/rest-api/answers/#method-param-params]
8+
*/
9+
public var query: String
10+
}
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
package com.algolia.search.model.params
2+
3+
import com.algolia.search.model.Attribute
4+
import com.algolia.search.model.search.AlternativesAsExact
5+
import com.algolia.search.model.search.ExactOnSingleWordQuery
6+
import com.algolia.search.model.search.IgnorePlurals
7+
import com.algolia.search.model.search.Language
8+
import com.algolia.search.model.search.QueryType
9+
import com.algolia.search.model.search.RemoveStopWords
10+
import com.algolia.search.model.search.RemoveWordIfNoResults
11+
import com.algolia.search.model.search.ResponseFields
12+
import com.algolia.search.model.search.SortFacetsBy
13+
import com.algolia.search.model.search.TypoTolerance
14+
import com.algolia.search.model.settings.AdvancedSyntaxFeatures
15+
import com.algolia.search.model.settings.Distinct
16+
17+
public interface BaseParameters {
18+
19+
/**
20+
* Gives control over which attributes to retrieve and which not to retrieve.
21+
* Engine default: [*]
22+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/attributesToRetrieve/?language=kotlin]
23+
*/
24+
public var attributesToRetrieve: List<Attribute>?
25+
26+
/**
27+
* Maximum number of facet values to return for each facet during a regular search.
28+
* Engine default: 100
29+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/?language=kotlin]
30+
*/
31+
public var maxValuesPerFacet: Int?
32+
33+
/**
34+
* Engine default: [SortFacetsBy.Count]
35+
* Controls how facet values are sorted.
36+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/sortFacetValuesBy/?language=kotlin]
37+
*/
38+
public var sortFacetsBy: SortFacetsBy?
39+
40+
/**
41+
* List of attributes to highlight.
42+
* Engine default: [*]
43+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/attributesToHighlight/?language=kotlin]
44+
*/
45+
public var attributesToHighlight: List<Attribute>?
46+
47+
/**
48+
* The HTML string to insert before the highlighted parts in all highlight and snippet results.
49+
* Needs to be used along [highlightPostTag].
50+
* Engine default: "<em>"
51+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/highlightPreTag/?language=kotlin]
52+
*/
53+
public var highlightPreTag: String?
54+
55+
/**
56+
* The HTML string to insert after the highlighted parts in all highlight and snippet results.
57+
* Needs to be used along [highlightPreTag].
58+
* Engine default: "</em>"
59+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/highlightPostTag/?language=kotlin]
60+
*/
61+
public var highlightPostTag: String?
62+
63+
/**
64+
* String used as an ellipsis indicator when a snippet is truncated.
65+
* Engine default: "…" (U+2026, HORIZONTAL ELLIPSIS)
66+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/snippetEllipsisText/?language=kotlin]
67+
*/
68+
public var snippetEllipsisText: String?
69+
70+
/**
71+
* Restrict highlighting and snippeting to items that matched the query.
72+
* Engine default: false
73+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/restrictHighlightAndSnippetArrays/?language=kotlin]
74+
*/
75+
public var restrictHighlightAndSnippetArrays: Boolean?
76+
77+
/**
78+
* Minimum number of characters a word in the query name must contain to accept matches with 1 typo.
79+
* Engine default: 4
80+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/minWordSizefor1Typo/?language=kotlin]
81+
*/
82+
public var minWordSizeFor1Typo: Int?
83+
84+
/**
85+
* Minimum number of characters a word in the query name must contain to accept matches with 2 typos.
86+
* Engine default: 8
87+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/minWordSizefor2Typos/?language=kotlin]
88+
*/
89+
public var minWordSizeFor2Typos: Int?
90+
91+
/**
92+
* Controls whether typo tolerance is enabled and how it is applied.
93+
* Engine defaults: true
94+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/typoTolerance/?language=kotlin]
95+
*/
96+
public var typoTolerance: TypoTolerance?
97+
98+
/**
99+
* Whether to allow typos on numbers (“numeric tokens”) in the query name.
100+
* Engine default: true
101+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/allowTyposOnNumericTokens/?language=kotlin]
102+
*/
103+
public var allowTyposOnNumericTokens: Boolean?
104+
105+
/**
106+
* List of attributes on which you want to disable typo tolerance.
107+
* Engine default: []
108+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/disabletypotoleranceonattributes/?language=kotlin]
109+
*/
110+
public var disableTypoToleranceOnAttributes: List<Attribute>?
111+
112+
/**
113+
* Treats singular, plurals, and other forms of declensions as matching terms.
114+
* Engine default: false
115+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/ignorePlurals/?language=kotlin]
116+
*/
117+
public var ignorePlurals: IgnorePlurals?
118+
119+
/**
120+
* Removes stop (task) words from the query before executing it.
121+
* Engine default: false
122+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/removeStopWords/?language=kotlin]
123+
*/
124+
public var removeStopWords: RemoveStopWords?
125+
126+
/**
127+
* Sets the languages to be used by language-specific settings and functionalities such as [ignorePlurals],
128+
* [removeStopWords], and [CJK word-detection][https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#using-a-language-specific-dictionary-for-cjk-words].
129+
* Engine default: []
130+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/queryLanguages/?language=kotlin]
131+
*/
132+
public var queryLanguages: List<Language>?
133+
134+
/**
135+
* Whether rules should be globally enabled.
136+
* Engine default: true
137+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/enableRules/?language=kotlin]
138+
*/
139+
public var enableRules: Boolean?
140+
141+
/**
142+
* Controls if and how query words are interpreted as [prefixes][https://www.algolia.com/doc/guides/textual-relevance/prefix-search/?language=kotlin].
143+
* Engine default: [QueryType.PrefixLast]
144+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/queryType/?language=kotlin]
145+
*/
146+
public var queryType: QueryType?
147+
148+
/**
149+
* Selects a strategy to remove words from the query when it doesn’t match any hits.
150+
* Engine default: [RemoveWordIfNoResults.None]
151+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/removeWordsIfNoResults/?language=kotlin]
152+
*/
153+
public var removeWordsIfNoResults: RemoveWordIfNoResults?
154+
155+
/**
156+
* Enables the advanced query syntax.
157+
* Engine default: false
158+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/advancedSyntax/?language=kotlin]
159+
*/
160+
public var advancedSyntax: Boolean?
161+
162+
/**
163+
* A list of words that should be considered as optional when found in the query.
164+
* Engine default: []
165+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/optionalWords/?language=kotlin]
166+
*/
167+
public var optionalWords: List<String>?
168+
169+
/**
170+
* List of [Attribute] on which you want to disable the exact ranking criterion.
171+
* Engine default: []
172+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/disableExactOnAttributes/?language=kotlin]
173+
*/
174+
public var disableExactOnAttributes: List<Attribute>?
175+
176+
/**
177+
* Controls how the exact ranking criterion is computed when the query contains only one word.
178+
* Engine default: [ExactOnSingleWordQuery.Attribute]
179+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/exactOnSingleWordQuery/?language=kotlin]
180+
*/
181+
public var exactOnSingleWordQuery: ExactOnSingleWordQuery?
182+
183+
/**
184+
* List of alternatives that should be considered an exact match by the exact ranking criterion.
185+
* Engine default: [[AlternativesAsExact.IgnorePlurals], [AlternativesAsExact.SingleWordSynonym]]
186+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/alternativesAsExact/?language=kotlin]
187+
*/
188+
public var alternativesAsExact: List<AlternativesAsExact>?
189+
190+
/**
191+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters//?language=kotlin]
192+
*/
193+
public var advancedSyntaxFeatures: List<AdvancedSyntaxFeatures>?
194+
195+
/**
196+
* Enables de-duplication or grouping of results.
197+
* Engine default: 0
198+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/distinct/?language=kotlin]
199+
*/
200+
public var distinct: Distinct?
201+
202+
/**
203+
* Whether to highlight and snippet the original word that matches the synonym or the synonym itself.
204+
* Engine default: true
205+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters//?language=kotlin]
206+
*/
207+
public var replaceSynonymsInHighlight: Boolean?
208+
209+
/**
210+
* Precision of the proximity ranking criterion.
211+
* Engine default: 1
212+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/minProximity/?language=kotlin]
213+
*/
214+
public var minProximity: Int?
215+
216+
/**
217+
* Choose which fields the response will contain. Applies to search and browse queries.
218+
* Engine default: [ResponseFields.All]
219+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/responseFields/?language=kotlin]
220+
*/
221+
public var responseFields: List<ResponseFields>?
222+
223+
/**
224+
* Maximum number of facet hits to return during a search for facet values.
225+
* Engine default: 10
226+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/maxFacetHits/?language=kotlin]
227+
*/
228+
public var maxFacetHits: Int?
229+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.algolia.search.model.params
2+
3+
import com.algolia.search.model.search.Snippet
4+
5+
public interface CommonParameters : BaseParameters {
6+
7+
/**
8+
* List of attributes to snippet.
9+
* Engine default: []
10+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/?language=kotlin]
11+
*/
12+
public var attributesToSnippet: List<Snippet>?
13+
14+
/**
15+
* Set the number of hits per page.
16+
* Engine default: 20
17+
* [Documentation][https://www.algolia.com/doc/api-reference/api-parameters/hitsPerPage/?language=kotlin]
18+
*/
19+
public var hitsPerPage: Int?
20+
}

0 commit comments

Comments
 (0)