|
1 | 1 | import 'dart:convert';
|
2 | 2 | import 'package:dio/dio.dart';
|
3 | 3 | import 'result.dart';
|
| 4 | +import 'search_query.dart'; |
4 | 5 | import 'searchable.dart';
|
5 | 6 | import 'settings/_exports.dart';
|
6 | 7 | import 'tasks_results.dart';
|
@@ -126,30 +127,33 @@ class MeiliSearchIndexImpl implements MeiliSearchIndex {
|
126 | 127 | String? highlightPostTag,
|
127 | 128 | MatchingStrategy? matchingStrategy,
|
128 | 129 | }) async {
|
129 |
| - final data = <String, Object?>{ |
130 |
| - 'q': query, |
131 |
| - 'offset': offset, |
132 |
| - 'limit': limit, |
133 |
| - 'page': page, |
134 |
| - 'hitsPerPage': hitsPerPage, |
135 |
| - 'filter': filter ?? filterExpression?.transform(), |
136 |
| - 'sort': sort, |
137 |
| - 'facets': facets, |
138 |
| - 'attributesToRetrieve': attributesToRetrieve, |
139 |
| - 'attributesToCrop': attributesToCrop, |
140 |
| - 'cropLength': cropLength, |
141 |
| - 'attributesToHighlight': attributesToHighlight, |
142 |
| - 'showMatchesPosition': showMatchesPosition, |
143 |
| - 'cropMarker': cropMarker, |
144 |
| - 'highlightPreTag': highlightPreTag, |
145 |
| - 'highlightPostTag': highlightPostTag, |
146 |
| - 'matchingStrategy': matchingStrategy?.name, |
147 |
| - }; |
148 |
| - data.removeWhere((k, v) => v == null); |
149 |
| - final response = await http |
150 |
| - .postMethod<Map<String, Object?>>('/indexes/$uid/search', data: data); |
151 |
| - |
152 |
| - return Searcheable.createSearchResult(response.data!); |
| 130 | + final data = SearchQuery( |
| 131 | + indexUid: uid, |
| 132 | + query: query, |
| 133 | + offset: offset, |
| 134 | + limit: limit, |
| 135 | + page: page, |
| 136 | + hitsPerPage: hitsPerPage, |
| 137 | + filter: filter, |
| 138 | + filterExpression: filterExpression, |
| 139 | + sort: sort, |
| 140 | + facets: facets, |
| 141 | + attributesToRetrieve: attributesToRetrieve, |
| 142 | + attributesToCrop: attributesToCrop, |
| 143 | + cropLength: cropLength, |
| 144 | + attributesToHighlight: attributesToHighlight, |
| 145 | + showMatchesPosition: showMatchesPosition, |
| 146 | + cropMarker: cropMarker, |
| 147 | + highlightPreTag: highlightPreTag, |
| 148 | + highlightPostTag: highlightPostTag, |
| 149 | + matchingStrategy: matchingStrategy, |
| 150 | + ).toMap(); |
| 151 | + |
| 152 | + final response = await http.postMethod<Map<String, Object?>>( |
| 153 | + '/indexes/$uid/search', |
| 154 | + data: data..remove('indexUid')); |
| 155 | + |
| 156 | + return Searcheable.createSearchResult(response.data!, indexUid: uid); |
153 | 157 | }
|
154 | 158 |
|
155 | 159 | //
|
|
0 commit comments