290 likes | 419 Views
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
E N D
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 • 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 • Requests • The base URL of the API is: • http://54.228.180.124:8080/search-api/v1/ • Resource Types • When you formulate a REST query, you have to decide which resource type you want. • AKIF or AGRIF 6
search-api • akif • 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
useful calls for search-api 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 Pagination Page Size Sorting Results Limit facets Combine all the previous :) Fetching specific items Full documentation: http://54.228.180.124:8080/search-api/ 11
Contents • The search-API • Useful calls for search-API • The response • Tutorial on how to build finder over the search-API 12
the response let’s say we make the following request ../akif?q=dove&facets=set&set=oeorganiceprints&page_size=10&page=1 13
the response Response: { "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 14
Contents • The search-API • Useful calls for search-API • The response • Tutorial : how to build a finder over the search-API 15
tutorial : how to build a finder over search-api 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 What are we going to create? 18
tutorial : how to build a finder over search-api Step 1 Download the source code from github https://github.com/agroknow/ak-finder 19
tutorial : how to build a finder over search-api Step 2 Understand 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 20
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 21
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 :) 22
tutorial : how to build a finder over search-api Step 3 The 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"] }, 23
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"] 24
tutorial : how to build a finder over search-api Step 4 Configure the finder : configuration + UI 25
tutorial : how to build a finder over search-api Step 4 Configure the finder : configuration + UI 26
tutorial : how to build a finder over search-api Step 5 Match it with your style :) 27
tutorial : how to build a finder over search-api Step 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. 28
Thank you! Mathioudakis Theodore Agro-Know Technologies mathiou@agroknow.gr