11import { AxiosError } from "axios"
22import { ClientRequest } from "http"
3+ import { UrlObject } from "url"
34
45// TODO: similarity https://lucene.apache.org/solr/guide/7_5/other-schema-elements.html#similarity
56// TODO: unique key https://lucene.apache.org/solr/guide/7_5/other-schema-elements.html#unique-key
67// TODO: dynamic fields https://lucene.apache.org/solr/guide/7_5/dynamic-fields.html
78// TODO: copying fields https://lucene.apache.org/solr/guide/7_5/copying-fields.html
8-
9- /**
10- * @file
11- * @see https://lucene.apache.org/solr/guide/7_5/v2-api.html
12- */
9+ // https://lucene.apache.org/solr/guide/7_5/v2-api.html
1310
1411/**
1512 * Field types that are available in Solr (except deprecated fields).
1613 * @see https://lucene.apache.org/solr/guide/7_5/field-types-included-with-solr.html#field-types-included-with-solr
1714 */
18- export type FieldTypesIncludedInSolr =
15+ type FieldTypesIncludedInSolr =
1916 | "solr.BinaryField"
2017 | "solr.BoolField"
2118 | "solr.CollationField"
@@ -234,58 +231,18 @@ interface FieldTypeDefaultProperties {
234231 large ?: boolean
235232}
236233
237- /**
238- * Fields are defined in the fields element of `schema.xml`.
239- * Once you have the **field types** set up, defining the fields themselves is simple.
240- *
241- * @see https://lucene.apache.org/solr/guide/7_5/defining-fields.html
242- * @see https://lucene.apache.org/solr/guide/7_5/defining-fields.html#optional-field-type-override-properties
243- */
244- export type FieldProperties = FieldGeneralProperties &
245- FieldTypeDefaultProperties
246-
247- /**
248- * A field type defines the analysis that will occur on a field when documents are indexed
249- * or queries are sent to the index.
250- * A field type definition can include four types of information:
251- * - The `name` of the field type (**mandatory**).
252- * - An implementation `class` name (**mandatory**).
253- * - If the field type is `TextField`, a description of the field analysis for the field type.
254- * - Field type properties - depending on the implementation class,
255- * some properties **may be mandatory**.
256- *
257- * The field type `class` determines most of the behavior of a field type, but optional properties
258- * can also be defined.
259- *
260- * The properties that can be specified for a given field type fall into three major categories:
261- * - Properties specific to the field type’s class.
262- * - General Properties {@link FieldTypeGeneralProperties} that Solr supports for any field type.
263- * - Field Default Properties {@link FieldTypeDefaultProperties} that can be specified on the field
264- * type that will be inherited by fields that use this type instead of the default behavior.
265- */
266- export type FieldTypeProperties = FieldTypeGeneralProperties &
267- FieldTypeDefaultProperties
268-
269234type SolrFragmentWithId = {
270235 id : string
271236 [ key : string ] : string | string [ ]
272237}
273238
274- type SolrDataValue =
275- | string
276- | string [ ]
277- | SolrFragmentWithId
278- | SolrFragmentWithId [ ]
279-
280- export interface SolrData {
281- [ key : string ] : SolrDataValue
282- }
283-
284- export interface SolrDocument {
285- id : string
286- _childDocuments_ ?: SolrFragmentWithId | SolrFragmentWithId [ ]
287- [ key : string ] : SolrDataValue | SolrData
288- }
239+ // TODO: SolrDataValue
240+ type SolrDataValue = any
241+ // type SolrDataValue =
242+ // | string
243+ // | string[]
244+ // | SolrFragmentWithId
245+ // | SolrFragmentWithId[]
289246
290247/**
291248 * This type definition contains just the most important parts.
@@ -296,61 +253,129 @@ interface SolrResponseHeader {
296253 QTime : number
297254}
298255
299- /**
300- * This type definition contains just the most important parts.
301- */
302- export interface SolrResponse {
303- status ?: string
304- response ?: {
305- docs : SolrDocument [ ]
306- numFound : number
307- start : number
308- }
309- responseHeader : SolrResponseHeader
256+ interface TermsFacet {
257+ buckets : { val : string ; count : number } [ ]
310258}
311259
312- /**
313- * This type definition contains just the most important parts.
314- */
315- export interface SolrException {
316- config
317- message : string
318- request : ClientRequest
319- response : {
260+ interface FacetFunctionResult {
261+ [ facetName : string ] : number
262+ }
263+
264+ declare global {
265+ interface SolrData {
266+ [ key : string ] : SolrDataValue
267+ }
268+
269+ /**
270+ * Fields are defined in the fields element of `schema.xml`.
271+ * Once you have the **field types** set up, defining the fields themselves is simple.
272+ *
273+ * @see https://lucene.apache.org/solr/guide/7_5/defining-fields.html
274+ * @see https://lucene.apache.org/solr/guide/7_5/defining-fields.html#optional-field-type-override-properties
275+ */
276+ type FieldProperties = FieldGeneralProperties & FieldTypeDefaultProperties
277+
278+ /**
279+ * A field type defines the analysis that will occur on a field when documents are indexed
280+ * or queries are sent to the index.
281+ * A field type definition can include four types of information:
282+ * - The `name` of the field type (**mandatory**).
283+ * - An implementation `class` name (**mandatory**).
284+ * - If the field type is `TextField`, a description of the field analysis for the field type.
285+ * - Field type properties - depending on the implementation class,
286+ * some properties **may be mandatory**.
287+ *
288+ * The field type `class` determines most of the behavior of a field type, but optional properties
289+ * can also be defined.
290+ *
291+ * The properties that can be specified for a given field type fall into three major categories:
292+ * - Properties specific to the field type’s class.
293+ * - General Properties {@link FieldTypeGeneralProperties} that Solr supports for any field type.
294+ * - Field Default Properties {@link FieldTypeDefaultProperties} that can be specified on the field
295+ * type that will be inherited by fields that use this type instead of the default behavior.
296+ */
297+ type FieldTypeProperties = FieldTypeGeneralProperties &
298+ FieldTypeDefaultProperties
299+
300+ interface SolrDocument {
301+ id : string
302+ _childDocuments_ ?: SolrFragmentWithId | SolrFragmentWithId [ ]
303+ [ key : string ] : SolrDataValue | SolrData
304+ }
305+
306+ /**
307+ * This type definition contains just the most important parts.
308+ */
309+ interface SolrResponse {
310+ status ?: string
311+ facets ?: {
312+ count ?: number
313+ } & {
314+ [ facetName : string ] : ( TermsFacet | FacetFunctionResult ) [ ] // TODO: to be completed
315+ }
316+ response ?: {
317+ docs : SolrDocument [ ]
318+ numFound : number
319+ start : number
320+ }
321+ responseHeader : SolrResponseHeader
322+ }
323+
324+ /**
325+ * This type definition contains just the most important parts.
326+ */
327+ interface SolrException {
320328 config
321- data : {
322- error : {
323- code : number
324- details : {
325- errorMessages : string [ ]
326- [ key : string ] : object
327- } [ ]
328- metadata : string [ ]
329+ message : string
330+ request : ClientRequest
331+ response : {
332+ config
333+ data : {
334+ error : {
335+ code : number
336+ details : {
337+ errorMessages : string [ ]
338+ [ key : string ] : object
339+ } [ ]
340+ metadata : string [ ]
341+ }
342+ responseHeader : SolrResponseHeader
329343 }
330- responseHeader : SolrResponseHeader
344+ headers
345+ request : ClientRequest
346+ status : number
347+ statusText : string
331348 }
332- headers
333- request : ClientRequest
334- status : number
335- statusText : string
349+ stack : string
336350 }
337- stack : string
338- }
339351
340- export interface SolrSelect {
341- q : string
342- fl ?: string
343- fq ?: string [ ]
344- start ?: number
345- sort ?: string
346- rows ?: number
347- hl ?: "on" | "off"
348- "hl.simple.pre" ?: string
349- "hl.simple.post" ?: string
350- "hl.fl" ?: string
351- debugQuery ?: "on" | "off"
352- indent ?: "off" | "on"
353- wt ?: "json" | "xml" | "python" | "ruby" | "php" | "csv"
354- "json.facet" ?: object
355- facet ?:"on" | "off"
352+ interface SolrQuery {
353+ query ?
354+ filter ?
355+ start ?
356+ limit ?
357+ sort ?
358+ facet ?
359+ params ?: {
360+ hl ?: "on" | "off"
361+ "hl.simple.pre" ?: string
362+ "hl.simple.post" ?: string
363+ "hl.fl" ?: string
364+ indent ?: "off" | "on"
365+ }
366+ }
367+
368+ interface SolrConfig {
369+ urlConfig : UrlObject & {
370+ query : {
371+ overwrite : boolean
372+ commitWithin : number
373+ wt : "json" | "xml" | "python" | "ruby" | "php" | "csv"
374+ [ key : string ] : any
375+ }
376+ }
377+ debug : boolean
378+ core ?: string
379+ apiPrefix : string
380+ }
356381}
0 commit comments