package no.uio.ifi.trackfind.rest.controllers;

import no.uio.ifi.trackfind.services.TrackFindService;
import org.apache.lucene.queryparser.classic.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class TrackFindController {

    private final TrackFindService trackFindService;

    @Autowired
    public TrackFindController(TrackFindService trackFindService) {
        this.trackFindService = trackFindService;
    }

    @GetMapping(path = "/reinit", produces = "application/json")
    public void reinit() throws Exception {
        trackFindService.updateIndex();
    }

    @GetMapping(path = "/metamodel", produces = "application/json")
    public Object getMetamodel() throws IOException, ParseException {
        return trackFindService.getMetamodel().asMap();
    }

    @GetMapping(path = "/search", produces = "application/json")
    public Object search(@RequestParam String query) throws IOException, ParseException {
        return trackFindService.search(query);
    }

}

@@ -220,16 +220,61 @@
 owired;%0A
+import org.springframework.util.StringUtils;%0A
 import o
@@ -324,16 +324,16 @@
 apping;%0A
-
 import o
@@ -476,16 +476,74 @@
 ception;
+%0Aimport java.util.Set;%0Aimport java.util.stream.Collectors;
 %0A%0A@RestC
@@ -1068,32 +1068,32 @@
 arseException %7B%0A
-
         return t
@@ -1131,32 +1131,752 @@
 asMap();%0A    %7D%0A%0A
+    @GetMapping(path = %22/attributes%22, produces = %22application/json%22)%0A    public Object getAttributes(@RequestParam(required = false) String expression) throws IOException, ParseException %7B%0A        Set%3CString%3E attributes = trackFindService.getMetamodel().asMap().keySet();%0A        if (StringUtils.isEmpty(expression)) %7B%0A            return attributes;%0A        %7D else %7B%0A            return attributes.stream().filter(a -%3E a.contains(expression)).collect(Collectors.toSet());%0A        %7D%0A    %7D%0A%0A    @GetMapping(path = %22/values%22, produces = %22application/json%22)%0A    public Object getValues(@RequestParam String attribute) throws IOException, ParseException %7B%0A        return trackFindService.getMetamodel().get(attribute);%0A    %7D%0A%0A
     @GetMapping(

Add separate methods for getting attributes and values.