Package org.compass.core

Examples of org.compass.core.CompassHits


        public Object doInCompass(CompassSession session) throws CompassException {
            Map options = SearchableMethodUtils.getOptionsArgument(args, defaultOptions, OVERRIDE_WITH_DEFAULTS_IF_NULL);
            CompassQuery compassQuery = compassQueryBuilder.buildQuery(grailsApplication, session, options, args);
            long start = System.currentTimeMillis();
            CompassHits hits = compassQuery.hits();
            if (LOG.isDebugEnabled()) {
                long time = System.currentTimeMillis() - start;
                LOG.debug("query: [" + compassQuery + "], [" + hits.length() + "] hits, took [" + time + "] millis");
            }
            if (hitCollector == null && searchResultFactory == null) {
                Assert.notNull(options.get("result"), "Missing 'result' option for search/query method: this should be provided if hitCollector/searchResultFactory are null to determine the type of result to return");
                String result = (String) options.get("result");
                if (result.equals("top")) {
                    hitCollector = new DefaultSearchableTopHitCollector();
                    searchResultFactory = new SearchableHitsOnlySearchResultFactory();
                } else if (result.equals("every")) {
                    hitCollector = new DefaultSearchableEveryHitCollector();
                    searchResultFactory = new SearchableHitsOnlySearchResultFactory();
                } else if (result.equals("searchResult")) {
                    hitCollector = new DefaultSearchableSubsetHitCollector();
                    searchResultFactory = new SearchableSubsetSearchResultFactory();
                } else if (result.equals("count")) {
                    hitCollector = new CountOnlyHitCollector();
                    searchResultFactory = new SearchableHitsOnlySearchResultFactory();
                } else {
                    throw new IllegalArgumentException("Invalid 'result' option for search/query method [" + result + "]. Supported values are ['searchResult', 'every', 'top']");
                }
            }
            int max = MapUtils.getIntValue(options, "max");
            int offset = MapUtils.getIntValue(options, "offset");
            int low = offset;

            Object collectedHits =  hitCollector.collect(hits,options);
            CompassDetachedHits compassDetachedHits = hits.detach(low,max);
            Object searchResult = searchResultFactory.buildSearchResult(hits, collectedHits, compassDetachedHits, options);

            doWithHighlighter(collectedHits, hits, searchResult, options);

            Object suggestOption = options.get("suggestQuery");
View Full Code Here

TOP

Related Classes of org.compass.core.CompassHits

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.