Package com.flaptor.indextank.api

Examples of com.flaptor.indextank.api.IndexEngineApi


    /**
     * @see java.lang.Runnable#run()
     */
    public void run() {
        IndexEngineApi api = (IndexEngineApi) ctx().getAttribute("api");
        try {
            Object parse = JSONValue.parseWithException(req().getReader());
            if(parse instanceof JSONObject) { // 200, 400, 404, 409, 503
                JSONObject jo = (JSONObject) parse;
                try {
View Full Code Here


    /**
     * @see java.lang.Runnable#run()
     */
    public void run() {
        IndexEngineApi api = (IndexEngineApi) ctx().getAttribute("api");
        HttpServletResponse res = res();
        HttpServletRequest req = req();

        String characterEncoding = api.getCharacterEncoding();
        try {
            req.setCharacterEncoding(characterEncoding);
            res.setCharacterEncoding(characterEncoding);
            res.setContentType("application/json");
        } catch (UnsupportedEncodingException ignored) {
View Full Code Here

    /**
     * @see java.lang.Runnable#run()
     */
    public void run() {
        IndexEngineApi api = (IndexEngineApi) ctx().getAttribute("api");
        HttpServletResponse res = res();

        String characterEncoding = api.getCharacterEncoding();
        try {
            req().setCharacterEncoding(characterEncoding);
            res.setCharacterEncoding(characterEncoding);
            res.setContentType("application/json");
        } catch (UnsupportedEncodingException ignored) {
        }

        String query = params("query");
        String field = params("field");
        String callback = params("callback");

        if (field == null || field.isEmpty()) {
            field = "text";
        }

        List<String> complete = api.complete(query, field);

        JSONObject json = new JSONObject();
        json.put("query", query);
        json.put("suggestions", complete);

View Full Code Here

    /**
     * @see java.lang.Runnable#run()
     */
    public void run() {
        IndexEngineApi api = (IndexEngineApi) ctx().getAttribute("api");
        HttpServletResponse res = res();

        String characterEncoding = api.getCharacterEncoding();
        try {
            req().setCharacterEncoding(characterEncoding);
            res.setCharacterEncoding(characterEncoding);
            res.setContentType("application/json");
        } catch (UnsupportedEncodingException ignored) {
        }

        String q = params("q");
        String fetchVariables = params("fetch_variables");
        String fetchCategories = params("fetch_categories");
        String fetch = params("fetch");
        String snippet = params("snippet");
        int start = QueryHelper.parseIntParam(params("start"), 0);
        int len = QueryHelper.parseIntParam(params("len"), 10);
        int function = QueryHelper.parseIntParam(params("function"), 0);
        Map<Integer, Double> vars = Maps.newHashMap();
        List<CategoryFilter> facetFilters = Lists.newArrayList();
        List<RangeFilter> variableRangeFilters = Lists.newArrayList();
        List<RangeFilter> functionRangeFilters = Lists.newArrayList();
        Map<String, String> extras = createExtraParameters(fetch, snippet,
                fetchVariables, fetchCategories);

        try {
            long t0 = System.currentTimeMillis();
            SearchResults results = api.search(q, start, len, function, vars, facetFilters, variableRangeFilters, functionRangeFilters, extras);
            long t1 = System.currentTimeMillis();
            double searchTime = (t1 - t0) / 1000;
            int matches = results.getMatches();
            Map<String, Map<String, Integer>> facets = toFacets(results.getFacets());
            String didYouMean = results.getDidYouMean();
View Full Code Here

TOP

Related Classes of com.flaptor.indextank.api.IndexEngineApi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.