Welcome to SKOS Suggester’s documentation!¶
HTTP API¶
Get endpoint¶
Endpoint for retrieving SKOS concepts by their unique identifier.
- GET /get¶
Get SKOS concepts by their URI
Example request:
GET /get?uri=http://id.worldcat.org/fast/869764 HTTP/1.1 Host: 127.0.0.1 Accept: application/json
Example request with multiple URIs:
GET /get?uri=http://id.worldcat.org/fast/1902995&uri=http://id.worldcat.org/fast/869764 Host: 127.0.0.1 Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "_links": {"self": {"href":"/search?uri=http://id.worldcat.org/fast/1902995&uri=http://id.worldcat.org/fast/869764"}}, "_embedded": {"concepts": [{"uri":"http://id.worldcat.org/fast/1902995", "prefLabel":"Depressions in motion pictures", "altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/869764", "prefLabel":"Commodore 64 (Computer)", "altLabels":[], "related":[{"label":"Electronic digital computers","uri":"http://id.worldcat.org/fast/907122"},{"label":"Commodore computers","uri":"http://id.worldcat.org/fast/869771"}]} ]}}
Expect the same response if only one concept is requested (i.e. a list of one concept).
Query Parameters: - uri – unique identifier of a SKOS concept
Status Codes: - 200 OK – request done
- 400 Bad Request – Bad request (if you don’t pass the parameter)
- 500 Internal Server Error – an exception occured
Search endpoint¶
Endpoint for searching SKOS concepts
- GET /search¶
Search for SKOS concepts by labels
Example request:
GET /search?q=http HTTP/1.1 Host: 127.0.0.1 Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json {"concepts":[ {"uri":"http://id.worldcat.org/fast/950001", "prefLabel":"HTTP (Computer network protocol)", "altLabels":["HyperText Transfer Protocol (Computer network protocol)"], "related":[ {"label":"Computer network protocols", "uri":"http://id.worldcat.org/fast/872279"} ]}, {"uri":"http://id.worldcat.org/fast/878049", "prefLabel":"Cookies (Computer science)", "altLabels":["Persistent cookies (Computer science)","HTTP cookies (Computer science)","Magic cookies (Computer science)"], "related":[ {"label":"Data structures (Computer science)", "uri":"http://id.worldcat.org/fast/887978"}]} ] }
Query Parameters: - q – search query
- count – number of results
- page – page (pagination)
Status Codes: - 200 OK – request done
- 400 Bad Request – Bad request (if you don’t pass the parameter)
- 404 Not Found – Not found
- 500 Internal Server Error – an exception occured
Suggest endpoint¶
Endpoint for suggesting SKOS concepts
Mainly used for type-ahead
- GET /suggest¶
Suggest SKOS concepts
Example request:
GET /suggest?q=secu HTTP/1.1 Host: 127.0.0.1 Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json {"concepts":[ {"uri":"http://id.worldcat.org/fast/872484","prefLabel":"Computer security","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/869774","prefLabel":"Common Data Security Architecture (Computer security standard)","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/1005142","prefLabel":"Macintosh (Computer)--Security measures","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/872590","prefLabel":"Computer software--Security measures","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/872437","prefLabel":"Computer programs--Security measures","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/872486","prefLabel":"Computer security--Computer programs","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/872485","prefLabel":"Computer security--Auditing","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/925719","prefLabel":"Firewalls (Computer security)","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/872487","prefLabel":"Computer security--Costs","altLabels":[],"related":[]}, {"uri":"http://id.worldcat.org/fast/872488","prefLabel":"Computer security--Evaluation","altLabels":[],"related":[]}] }
Query Parameters: - q – search query
- count – number of results
- page – page (pagination)
Status Codes: - 200 OK – request done
- 400 Bad Request – Bad request (if you don’t pass the parameter)
- 404 Not Found – Not found
- 500 Internal Server Error – an exception occured
Importers¶
RDF file importer¶
Imports SKOS concepts from an RDF file. This is the recommended method if you have a small dataset as it is easier to use.
Importing the file into SKOS suggester¶
Run the following command, where [path to file] is the path of the RDF file, and [configuration file] is the Dropwizard configuration file.
java -jar target/skos-suggester-1.0-SNAPSHOT.jar skosimport -f [path to file] [configuration file]
Jena TDB importer¶
Imports SKOS concepts from a Jena TDB dataset. This is the recommended method if you have a fairly large dataset (e.g. FAST (Faceted Application of Subject Terminology) topics).
Importing RDF files into Jena TDB¶
Run the following command, where [path to store] is the path of a directory, and [path to RDF file] is the RDF file to be imported.
tdbloader2 –loc [path to store] [path to RDF file]
See TDB commands documentation for more information.
Importing TDB into SKOS suggester¶
Run the following command, where [path to store] is the path of the TDB directory, and [configuration file] is the Dropwizard configuration file.
java -jar target/skos-suggester-1.0-SNAPSHOT.jar tdbimport -d [path to store] [configuration file]
Developers¶
Javadoc¶
uk.ac.ox.it.skossuggester¶
SkosSuggesterApplication¶
- public class SkosSuggesterApplication extends Application<AppConfiguration>¶
Methods¶
- public void initialize(Bootstrap<AppConfiguration> bootstrap)¶
- public void run(AppConfiguration configuration, Environment environment)¶
uk.ac.ox.it.skossuggester.cli¶
Skos¶
- public class Skos¶
Utility methods used by importers RDF -> SolrDocument
Author: martinfilliau
Fields¶
SkosFileImporter¶
- public class SkosFileImporter extends ConfiguredCommand<AppConfiguration>¶
Import SKOS concepts from an RDF file Easier to use than TdbImporter as it does not need an intermediary Jena TDB store, but might reach memory limits
Author: martinfilliau
Methods¶
- protected Collection<SolrInputDocument> getDocsFromFile(File file, String lang)¶
Import a given RDF file to the search index
Parameters: - file – RDF file
- lang – RDF format (RDF/XML, N-TRIPLE, TURTLE or N3)
Throws: Returns: collection of SolrInputDocument
- protected Collection<SolrInputDocument> getDocsFromModel(Model m)¶
Import a Model
Parameters: - m – Jena Model
Returns: collection of SolrInputDocument
- protected void run(Bootstrap<AppConfiguration> bootstrap, Namespace namespace, AppConfiguration configuration)¶
TdbImporter¶
- public class TdbImporter extends ConfiguredCommand<AppConfiguration>¶
Import SKOS concepts from a Jena TDB store More robust than SkosFileImporter for big data sets See http://jena.apache.org/documentation/tdb/
Author: martinfilliau
Methods¶
- protected void run(Bootstrap<AppConfiguration> btstrp, Namespace namespace, AppConfiguration configuration)¶
uk.ac.ox.it.skossuggester.configuration¶
uk.ac.ox.it.skossuggester.dao¶
SkosConceptsDao¶
- public class SkosConceptsDao¶
Encapsulates all queries to Solr
Author: martinfilliau
Constructors¶
Methods¶
- public Optional<SkosConcepts> get(List<String> uris)¶
Get documents by their unique IDs
Parameters: - uris – list of URIs
Returns: SkosConcepts or absent
- public Optional<SkosConcepts> search(String query, Integer start, Integer count)¶
Search for documents by a query string
Parameters: - query – string to search
- start – first document to retrieve
- count – number of documents to retrieve
Returns: SkosConcepts or absent
- public Optional<SkosConcepts> suggest(String query, Integer start, Integer count)¶
Search for documents by a query string Use the “suggest” handler which provides a light response
Parameters: - query – string to search
- start – first document to retrieve
- count – number of documents to retrieve
Returns: SkosConcepts or absent
uk.ac.ox.it.skossuggester.health¶
uk.ac.ox.it.skossuggester.jerseyutils¶
JsonIllegalArgumentExceptionMapper¶
- public class JsonIllegalArgumentExceptionMapper implements ExceptionMapper<IllegalArgumentException>¶
Methods¶
- public Response toResponse(IllegalArgumentException error)¶
uk.ac.ox.it.skossuggester.representations¶
SkosConcept¶
- public class SkosConcept¶
Represents a skos:concept
Author: martinfilliau
Methods¶
- public static SkosConcept fromSolr(SolrDocument doc)¶
Get a SkosConcept from a SolrDocument
Parameters: - doc – SolrDocument
Returns: SkosConcept
SkosConcepts¶
- public class SkosConcepts¶
Represents a list of SkosConcept
Author: martinfilliau
Constructors¶
- public SkosConcepts(List<SkosConcept> concepts)¶
Methods¶
- public void addConcept(SkosConcept concept)¶
Add a SkosConcept to the list of concepts
Parameters: - concept – SkosConcept
- public static SkosConcepts fromSolr(SolrDocumentList docs)¶
Get SkosConcepts from a SolrDocumentList
Parameters: - docs – SolrDocumentList
Returns: SkosConcepts
- public List<SkosConcept> getConcepts()¶
- public void setConcepts(List<SkosConcept> concepts)¶