-
Notifications
You must be signed in to change notification settings - Fork 252
ApiAdditions_PackageSearch
Provide access to the search server's package search capability through API.
-
Search by name
-
Search by version
-
Search by release NEEDS TO BE ADDED TO SEARCH SERVER
-
Search by arch
-
Channel
-
User
-
Key ?? ActivationKey?
-
Name Only
-
Name and Description
-
Name and Summary
-
Free form - allows lucene query for search on anything packages index.
-
name
-
version
-
filename
-
description
-
summary
-
arch
Note: The class which does the work for indexing packages is: com.redhat.satellite.search.scheduler.tasks.IndexPackagesTask To support searching by "release" we need to make a one line change to "indexPackage".
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("name", pkg.getName());
attrs.put("version", pkg.getPrettyVersion());
attrs.put("filename", pkg.getFileName());
attrs.put("description", pkg.getDescription());
attrs.put("summary", pkg.getSummary());
attrs.put("arch", pkg.getArch());
Need to add attrs.put("release", pkg.getRelease())
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("name", pkg.getName());
attrs.put("version", pkg.getPrettyVersion());
attrs.put("filename", pkg.getFileName());
attrs.put("description", pkg.getDescription());
attrs.put("summary", pkg.getSummary());
attrs.put("arch", pkg.getArch());
attrs.put("release", pkg.getRelease());
For background, the package model is populated from the DB query "listPackagesFromId" from spacewalk/search-server/src/config/com/redhat/satellite/search/db/package.xml
XmlRpcClient client = new XmlRpcClient(Config.get().getSearchServerUrl(), true);
List args = new ArrayList();
args.add(sessionId);
args.add("package");
String exampleQuery = "(name:(vim) description:(editor) arch:(i386) summary:(editor))"
args.add(exampleQuery);
List results = (List)client.invoke("index.search", args);
Query can be a string such as: (attributeName:(searchTerm) attributeName2:(searchTerm))
You can get a little fancier and add modifiers such as "AND", "NOT"
Lucene Query Syntax
-
String id - package ID corresponding to the ID in database, rhnPackage.id
-
String name - package Name corresponding to database, rhnPackageName.name
-
float score - lucene score from query, higher number is a better result
-
int rank - ranking, lower number is most relevant
The data returned from the search server is not ready to be returned to the api caller. You must first use the "id" and flesh out the package details from the DB.
Do you want to contribute to this wiki? See page WikiContribute for more info.