supported by eu projects
DESCRIPTION
Open Data in Agriculture. Hands-on with data infrastructures that can power your agricultural data products. 12/12/2013 Athens, Greece. Supported by EU projects. How to use the search-API at the front-end. Mathioudakis Theodore Agro-Know Technologies. Contents. The search-API - PowerPoint PPT PresentationTRANSCRIPT
Supported by EU projects
12/12/2013Athens, Greece
Open Data in AgricultureHands-on with data
infrastructures that can power your agricultural data products
Mathioudakis TheodoreAgro-Know Technologies
How to use the search-API at the front-end
Contents
๏ The search-API ๏ Useful calls for search-API๏ The response๏ Tutorial on how to build finder over the
search-API
3
Contents
๏ The search-API ๏ Useful calls for search-API๏ The response๏ Tutorial on how to build finder over the
search-API
4
search-api
search-api
RequestsThe base URL of the API is:http://54.228.180.124:8080/search-api/v1/
Resource TypesWhen you formulate a REST query, you have to decide which resource type you want.
AKIF or AGRIF
6
search-apiakif
The akif type is a data model to represent educational resources related to agriculture and biodiversity.
The RESTful URL to request data from the akif resource begins:http://54.228.180.124:8080/search-api/v1/akif/
agrif
The agrif type is a data model to represent bibliographic references on agricultural research and technology.
The RESTful URL to request data from the agrif resource begins:http://54.228.180.124:8080/search-api/v1/agrif/
7
Contents
๏ The search-API ๏ Useful calls for search-API๏ The response๏ Tutorial : how to build finder over the
search-API
8
1. Simple search http://<domain>/v1/akif?q=fossil (items with fossil anywhere in any field)
http://<domain>/v1/akif?q=* (all items)
2. Search within specific field http://<domain>/v1/akif?languageBlock.en.description=fossil (all items that has fossil in description )
9
useful calls for search-api
2. Search within specific field (cont’) …/akif?languageBlock.en.description=fossil&language=en (all items that has element fossil in description and language = en)
3. Faceted Search (Facets tell you the most common values for certain fields in a collection of items) …/akif?facets=set,language (We define “set” and “language” as facets)
10
useful calls for search-api
4. Other calls PaginationPage SizeSorting ResultsLimit facetsCombine all the previous :)
Fetching specific items
Full documentation:http://54.228.180.124:8080/search-api/
11
useful calls for search-api
Contents
๏ The search-API ๏ Useful calls for search-API๏ The response๏ Tutorial on how to build finder over the
search-API
12
let’s say we make the following request
../akif?q=dove&facets=set&set=oeorganiceprints&page_size=10&page=1
13
the response
14
the responseResponse: { "total" : 1, "time" : 5, "page" : 1, "pageSize" : 10, "sortOrder" : "asc", "facets" : { "set" : { "_type" : "terms", "missing" : 0, "total" : 1, "other" : 0, "terms" : [ { "term" : "oeorganiceprints", "count" : 1 } ] } }, "results" : [ { "creationDate" : "2013-04-17", "lastUpdateDate" : "2
Contents
๏ The search-API ๏ Useful calls for search-API๏ The response๏ Tutorial : how to build a finder over
the search-API
15
Choice 1: Use javascript(ajax) to call the API.
Create a UI to show the json response.
16
tutorial : how to build a finder over search-api
Choice 2: Use our code to easily implement a simple finder
on your server.
Follows the tutorial
17
tutorial : how to build a finder over search-api
18
What are we going to create?tutorial : how to build a finder over search-api
19
Step 1Download the source code from githubhttps://github.com/agroknow/ak-finder
tutorial : how to build a finder over search-api
20
tutorial : how to build a finder over search-api
Step 2Understand the structure
• MVC model using Angular JS• /app/controllers : contains the controllers• /assets : contains images e.t.c• /config : contains configuration
and mapping files• /css : contains the css(.less) files• /finder : contains the html files
for search page and view item page
21
tutorial : how to build a finder over search-api
Step 2 (cont)Understand the structure *advanced
Magic happens in controllers files and conf.json file.
•…/controllers/search : controllers for search page•…/controllers/view_item : controllers for view_item
22
tutorial : how to build a finder over search-api
Step 2 (cont)Understand the structure *for the rest of us
Magic happens in /config/conf.json file :)
23
tutorial : how to build a finder over search-api
Step 3The conf.json file
"baseUrl": "http://54.228.180.124:8080/search-api/v1/akif?", "enableFacets": true, "enablePaginationBottom": false, "enablePaginationTop": false, "facets": ["set","language"], "limitPagination": 10, "limit_facets": { "set":["oeintute","aglrgfsp"] },
24
tutorial : how to build a finder over search-api
Step 3(cont)The conf.json file
"limit_facets_number": 4, "mappings_file": "../config/facets_mappings.json", "maxTextLength": 300, "pageSize": 20, "selectedLanguage": "en", "snippetElements": [“title", “description", "languageBlocks.en.keywords"]
25
tutorial : how to build a finder over search-apiStep 4
Configure the finder : configuration + UI
26
tutorial : how to build a finder over search-apiStep 4
Configure the finder : configuration + UI
27
tutorial : how to build a finder over search-apiStep 5
Match it with your style :)
28
tutorial : how to build a finder over search-apiStep 5
Match it with your style :)
All you need to do is to change the colours in the css(.less) file and find the combination you like.
Of course you are all free to create and change the code in any way you like.
Thank you!
Mathioudakis TheodoreAgro-Know [email protected]