Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions app/lib/search/search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,7 @@ class ServiceSearchQuery {
ServiceSearchQuery change({
TextMatchExtent? textMatchExtent,
}) {
return ServiceSearchQuery(SearchRequestData(
query: query,
tags: _data.tags,
publisherId: publisherId,
order: order,
minPoints: minPoints,
offset: offset,
limit: limit,
textMatchExtent: textMatchExtent ?? this.textMatchExtent,
));
return ServiceSearchQuery(_data.replace(textMatchExtent: textMatchExtent));
}

late final parsedQuery = ParsedQueryText.parse(_data.query);
Expand Down
19 changes: 18 additions & 1 deletion app/test/service/entrypoint/search_index_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:_pub_shared/search/search_request_data.dart';
import 'package:path/path.dart' as p;
import 'package:pub_dev/search/search_service.dart';
import 'package:pub_dev/search/updater.dart';
Expand All @@ -28,14 +29,18 @@ void main() {
description: 'Annotation metadata for JSON serialization.',
tags: ['sdk:dart'],
),
PackageDocument(
package: 'other_pkg',
description: 'Some awesome package',
),
],
snapshotPath,
);

runner = await startSearchIsolate(snapshot: snapshotPath);

// index calling the sendport
final searchIndex = IsolateSearchIndex(runner);
final searchIndex = LatencyAwareSearchIndex(IsolateSearchIndex(runner));
expect(await searchIndex.isReady(), true);

// text query - result from package index
Expand All @@ -52,6 +57,18 @@ void main() {
},
],
});

// packages-based filtering works
final rs2 = await searchIndex.search(
ServiceSearchQuery(SearchRequestData(packages: ['other_pkg'])));
expect(rs2.toJson(), {
'timestamp': isNotEmpty,
'totalCount': 1,
'sdkLibraryHits': [],
'packageHits': [
{'package': 'other_pkg', 'score': isNotNull}
],
});
});
}, timeout: Timeout(Duration(minutes: 5)));
});
Expand Down
3 changes: 2 additions & 1 deletion pkg/_pub_shared/lib/search/search_request_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class SearchRequestData {
String? query,
List<String>? tags,
List<String>? packages,
TextMatchExtent? textMatchExtent,
}) {
return SearchRequestData(
query: query ?? this.query,
Expand All @@ -103,7 +104,7 @@ class SearchRequestData {
order: order,
offset: offset,
limit: limit,
textMatchExtent: textMatchExtent,
textMatchExtent: textMatchExtent ?? this.textMatchExtent,
);
}
}
Expand Down