org.alfresco.service.cmr.search.ResultSet Java Examples
The following examples show how to use
org.alfresco.service.cmr.search.ResultSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaggingServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodesAndCountByTagName(StoreRef) */ @Override public List<Pair<String, Integer>> findTaggedNodesAndCountByTagName(StoreRef storeRef) { String queryTaggeble = "ASPECT:\"" + ContentModel.ASPECT_TAGGABLE + "\"" + "-ASPECT:\"" + ContentModel.ASPECT_WORKING_COPY + "\""; SearchParameters sp = new SearchParameters(); sp.setQuery(queryTaggeble); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.addStore(storeRef); sp.addFieldFacet(new FieldFacet("TAG")); ResultSet resultSet = null; try { // Do the search for nodes resultSet = this.searchService.query(sp); return resultSet.getFieldFacet("TAG"); } finally { if (resultSet != null) { resultSet.close(); } } }
Example #2
Source File: ResultMapper.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * Gets SolrJSONResultSet class if there is one. * @param results * @return */ protected SolrJSONResultSet findSolrResultSet(ResultSet results) { ResultSet theResultSet = results; if (results instanceof FilteringResultSet) { theResultSet = ((FilteringResultSet) results).getUnFilteredResultSet(); } if (theResultSet instanceof SolrJSONResultSet) { return (SolrJSONResultSet) theResultSet; } return null; }
Example #3
Source File: ResultMapperTests.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private ResultSet mockResultset(List<Long> archivedNodes, List<Long> versionNodes) throws JSONException { NodeService nodeService = mock(NodeService.class); when(nodeService.getNodeRef(any())).thenAnswer(new Answer<NodeRef>() { @Override public NodeRef answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); //If the DBID is in the list archivedNodes, instead of returning a noderef return achivestore noderef if (archivedNodes.contains(args[0])) return new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, GUID.generate()); if (versionNodes.contains(args[0])) return new NodeRef(StoreMapper.STORE_REF_VERSION2_SPACESSTORE, GUID.generate()+args[0]); return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); } }); SearchParameters sp = new SearchParameters(); sp.setBulkFetchEnabled(false); JSONObject json = new JSONObject(new JSONTokener(JSON_REPONSE)); ResultSet results = new SolrJSONResultSet(json,sp,nodeService, null, LimitBy.FINAL_SIZE, 10); return results; }
Example #4
Source File: LuceneCategoryServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname) { ResultSet resultSet = null; try { resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene", "PATH:\"/" + getPrefix(qname.getNamespaceURI()) + ISO9075.encode(qname.getLocalName()) + "\"", null); Set<NodeRef> nodeRefs = new HashSet<NodeRef>(resultSet.length()); for (ResultSetRow row : resultSet) { nodeRefs.add(row.getNodeRef()); } return nodeRefs; } finally { if (resultSet != null) { resultSet.close(); } } }
Example #5
Source File: LuceneCategoryServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public Collection<ChildAssociationRef> getClassifications(StoreRef storeRef) { ResultSet resultSet = null; try { resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene", "PATH:\"//cm:categoryRoot/*\"", null); return resultSetToChildAssocCollection(resultSet); } finally { if (resultSet != null) { resultSet.close(); } } }
Example #6
Source File: TaggingServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(StoreRef, java.lang.String) */ public List<NodeRef> findTaggedNodes(StoreRef storeRef, String tag) { // Lower the case of the tag tag = tag.toLowerCase(); ResultSet resultSet= null; try { // Do the search for nodes resultSet = this.searchService.query( storeRef, SearchService.LANGUAGE_LUCENE, "+PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\""); List<NodeRef> nodeRefs = resultSet.getNodeRefs(); return nodeRefs; } finally { if(resultSet != null) {resultSet.close();} } }
Example #7
Source File: NodePropertiesMapperUtil.java From alfresco-mvc with Apache License 2.0 | 6 votes |
public <T> List<T> mapResultSet(final ResultSet results, final NodePropertiesMapper<T> mapper) { Assert.notNull(results, "[Assertion failed] - the results argument must be null"); Assert.notNull(mapper, "[Assertion failed] - the mapper argument must be null"); List<T> list = new ArrayList<>(); for (ResultSetRow resultSetRow : results) { Map<QName, Serializable> properties = new HashMap<>(); Set<QName> mappedQnames = mapper.getMappedQnames(); for (QName qName : mappedQnames) { properties.put(qName, resultSetRow.getValue(qName)); } list.add(mapper.mapNodeProperties(resultSetRow.getNodeRef(), properties)); } return list; }
Example #8
Source File: ACLEntryAfterInvocationProvider.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private QueryEngineResults decide(Authentication authentication, Object object, ConfigAttributeDefinition config, QueryEngineResults returnedObject) throws AccessDeniedException { Map<Set<String>, ResultSet> map = returnedObject.getResults(); Map<Set<String>, ResultSet> answer = new HashMap<Set<String>, ResultSet>(map.size(), 1.0f); for (Set<String> group : map.keySet()) { ResultSet raw = map.get(group); ResultSet permed; if (PagingLuceneResultSet.class.isAssignableFrom(raw.getClass())) { permed = decide(authentication, object, config, (PagingLuceneResultSet)raw); } else { permed = decide(authentication, object, config, raw); } answer.put(group, permed); } return new QueryEngineResults(answer); }
Example #9
Source File: ACLEntryAfterInvocationProvider.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Compute a (Weak)FilteringResultSet by selecting the first maxSize elements from returnedObject. * * @param maxSize * @param returnedObject * @return */ private ResultSet filterMaxCount(Integer maxSize, ResultSet returnedObject) { // If maxsize is not defined, than return the entire resultset. if (maxSize == null) { return returnedObject; } WeakFilteringResultSet filteringResultSet = new WeakFilteringResultSet(returnedObject); for (int i = 0; i < maxSize && i < returnedObject.length(); i++) { filteringResultSet.setIncluded(i, true); } LimitBy limitBy = returnedObject.length() > maxSize? LimitBy.FINAL_SIZE : LimitBy.UNLIMITED; filteringResultSet.setResultSetMetaData(new SimpleResultSetMetaData(limitBy, PermissionEvaluationMode.EAGER, returnedObject.getResultSetMetaData().getSearchParameters())); return filteringResultSet; }
Example #10
Source File: DBQueryTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Test that when a query is performed with a limit parameter, the number of results in the resultset * is influenced by limit while the numberOfFound value is not. */ @Test public void testAftsPagination() { String query = "=TYPE:\"cm:folder\" "; // this value is equals to the numer of folders inserted in createTestData method. int numFolders = 6; int count = 4; ResultSet results = query(SearchService.LANGUAGE_FTS_ALFRESCO, query, count); assertEquals("The number of results should be equal to count", results.length(), count); assertEquals("The number of founds should be equal to the number of folders, and not influenced" + "by the limit set to the query.", results.getNumberFound(), numFolders); }
Example #11
Source File: LockServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get the locks given a store and query string. * * @param storeRef the store reference * @param query the query string * @return the locked nodes * @deprecated Uses search and does not report on ephemeral locks. */ @Deprecated private List<NodeRef> getLocks(StoreRef storeRef, String query) { List<NodeRef> result = new ArrayList<NodeRef>(); ResultSet resultSet = null; try { resultSet = this.searchService.query( storeRef, SearchService.LANGUAGE_LUCENE, query); result = resultSet.getNodeRefs(); } finally { if (resultSet != null) { resultSet.close(); } } return result; }
Example #12
Source File: CMISQueryServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private ResultSet filterNotExistingNodes(ResultSet resultSet) { if (resultSet instanceof PagingLuceneResultSet) { ResultSet wrapped = ((PagingLuceneResultSet)resultSet).getWrapped(); if (wrapped instanceof FilteringResultSet) { FilteringResultSet filteringResultSet = (FilteringResultSet)wrapped; for (int i = 0; i < filteringResultSet.length(); i++) { NodeRef nodeRef = filteringResultSet.getNodeRef(i); /* filter node if it does not exist */ if (!nodeService.exists(nodeRef)) { filteringResultSet.setIncluded(i, false); } } } } return resultSet; }
Example #13
Source File: SharedLinkApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private static ResultSet mockResultSet(List<String> nodeIds) { List<ResultSetRow> resultSetRows = new LinkedList<>(); for (String nodeId : nodeIds) { ResultSetRow mockResultSetRow1 = mock(ResultSetRow.class); when(mockResultSetRow1.getNodeRef()).thenReturn(new NodeRef("workspace","SpacesStore" ,nodeId)); resultSetRows.add(mockResultSetRow1); } ResultSet mockSearchServiceQueryResultSet = mock(ResultSet.class); when(mockSearchServiceQueryResultSet.hasMore()).thenReturn(false); when(mockSearchServiceQueryResultSet.getNumberFound()).thenReturn(Long.valueOf(nodeIds.size())); when(mockSearchServiceQueryResultSet.length()).thenReturn(nodeIds.size()); when(mockSearchServiceQueryResultSet.iterator()).thenReturn(resultSetRows.iterator()); return mockSearchServiceQueryResultSet; }
Example #14
Source File: SolrSQLHttpClientTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** Check that a query can be combined with filter queries. */ @Test public void testExecuteQuery_filterQueries() throws JSONException { when(mockSearchParameters.getFilterQueries()).thenReturn(asList("FQ1", "FQ2")); // Call the method under test. ResultSet resultSet = solrSQLHttpClient.executeQuery(mockSearchParameters, LANGUAGE); assertEquals("Expected result to come back from HTTP call.", mockResultSet, resultSet); List<String> actual = stringJsonArrayToList(bodyCaptor.getValue().getJSONArray("filterQueries")); assertEquals("Unexpected filter queries in HTTP request.", actual, asList("FQ1", "FQ2")); }
Example #15
Source File: CMISResultSet.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public boolean hasMore() { for (ResultSet resultSet : wrapped.values()) { if (resultSet.hasMore()) { return true; } } return false; }
Example #16
Source File: CMISResultSet.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public int getLength() { for (ResultSet resultSet : wrapped.values()) { return resultSet.length(); } throw new IllegalStateException(); }
Example #17
Source File: ResultMapperTests.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testToCollectionWithPagingInfo() throws Exception { ResultSet results = mockResultset(Arrays.asList(514l), Arrays.asList(566l, VERSIONED_ID)); SearchRequestContext searchRequest = SearchRequestContext.from(SearchQuery.EMPTY); CollectionWithPagingInfo<Node> collectionWithPage = mapper.toCollectionWithPagingInfo(EMPTY_PARAMS, searchRequest, SearchQuery.EMPTY, results); assertNotNull(collectionWithPage); Long found = results.getNumberFound(); assertEquals(found.intValue(), collectionWithPage.getTotalItems().intValue()); Node firstNode = collectionWithPage.getCollection().stream().findFirst().get(); assertNotNull(firstNode.getSearch().getScore()); assertEquals(StoreMapper.LIVE_NODES, firstNode.getLocation()); collectionWithPage.getCollection().stream().forEach(aNode -> { List<HighlightEntry> high = aNode.getSearch().getHighlight(); if (high != null) { assertEquals(2, high.size()); HighlightEntry first = high.get(0); assertNotNull(first.getField()); assertNotNull(first.getSnippets()); } }); //1 deleted node in the test data assertEquals(1l, collectionWithPage.getCollection().stream().filter(node -> StoreMapper.DELETED.equals(node.getLocation())).count()); //1 version nodes in the test data (and 1 is not shown because it is in the archive store) assertEquals(1l, collectionWithPage.getCollection().stream().filter(node -> StoreMapper.VERSIONS.equals(node.getLocation())).count()); }
Example #18
Source File: DBQueryTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void queryWithCount(String ql, String query, int count, QName property, Boolean ascending) { SearchParameters sp = new SearchParameters(); sp.setLanguage(ql); sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL); sp.setQuery(query); sp.addStore(rootNodeRef.getStoreRef()); ResultSet results = serviceRegistry.getSearchService().query(sp); HashSet<NodeRef> found = new HashSet<NodeRef>(); Comparable last = null; for(ResultSetRow row :results) { assertFalse(found.contains( row.getNodeRef())); found.add(row.getNodeRef()); if(property != null) { Comparable current = (Comparable)nodeService.getProperty(row.getNodeRef(), property); if(last != null) { if((ascending == null) || (ascending)) { assert(last.compareTo(current) >= 0); } else { assert(last.compareTo(current) <= 0); } } last = current; } } assertEquals(count, results.length()); results.getResultSetMetaData(); results.close(); }
Example #19
Source File: ResultMapperTests.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private ResultSet mockResultset(String json) throws Exception { NodeService nodeService = mock(NodeService.class); JSONObject jsonObj = new JSONObject(new JSONTokener(json)); SearchParameters sp = new SearchParameters(); sp.setBulkFetchEnabled(false); ResultSet results = new SolrJSONResultSet(jsonObj, sp, nodeService, null, LimitBy.FINAL_SIZE, 10); return results; }
Example #20
Source File: DetachedResultSetRow.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Detached result set row * @param resultSet ResultSet * @param row ResultSetRow */ public DetachedResultSetRow(ResultSet resultSet, ResultSetRow row) { super(resultSet, row.getIndex()); car = row.getChildAssocRef(); properties = row.getValues(); }
Example #21
Source File: AbstractResultSetRowIterator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Create an iterator over the result set. Follows stadard ListIterator * conventions * * @param resultSet ResultSet */ public AbstractResultSetRowIterator(ResultSet resultSet) { super(); this.resultSet = resultSet; this.max = resultSet.length(); }
Example #22
Source File: SolrXPathQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ResultSet executeQuery(SearchParameters searchParameters) { String query = "PATH:\""+searchParameters.getQuery()+"\""; SearchParameters sp = searchParameters.copy(); sp.setLanguage(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO); sp.setQuery(query); return solrQueryLanguage.executeQuery(sp); }
Example #23
Source File: ResultMapperTests.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testInterval() throws Exception { ResultSet results = mockResultset(Collections.emptyList(),Collections.emptyList()); SearchQuery searchQuery = helper.searchQueryFromJson(); SearchRequestContext searchRequest = SearchRequestContext.from(searchQuery); SearchParameters searchParams = searchMapper.toSearchParameters(EMPTY_PARAMS, searchQuery, searchRequest); SearchContext searchContext = mapper.toSearchContext((SolrJSONResultSet) results, searchRequest, searchQuery, 0); //Facet intervals List<GenericFacetResponse> intervalFacets = searchContext.getFacets().stream() .filter(f -> f.getType().equals(FACET_TYPE.interval)).collect(Collectors.toList()); assertEquals(2, intervalFacets.size()); assertEquals("creator",intervalFacets.get(0).getLabel()); assertEquals("last",intervalFacets.get(0).getBuckets().get(0).getLabel()); assertEquals("cm:creator:<\"a\" TO \"b\"]",intervalFacets.get(0).getBuckets().get(0).getFilterQuery()); Object[] metrics = intervalFacets.get(0).getBuckets().get(0).getMetrics().toArray(); assertEquals(METRIC_TYPE.count,((SimpleMetric) metrics[0]).getType()); assertEquals("4",((SimpleMetric) metrics[0]).getValue().get("count")); metrics = intervalFacets.get(1).getBuckets().get(0).getMetrics().toArray(); assertEquals("TheCreated",intervalFacets.get(1).getLabel()); assertEquals("earlier",intervalFacets.get(1).getBuckets().get(0).getLabel()); assertEquals("cm:created:[\"*\" TO \"2016\">",intervalFacets.get(1).getBuckets().get(0).getFilterQuery()); assertEquals(METRIC_TYPE.count,((SimpleMetric) metrics[0]).getType()); assertEquals("5",((SimpleMetric) metrics[0]).getValue().get("count")); metrics = intervalFacets.get(1).getBuckets().get(1).getMetrics().toArray(); assertEquals("lastYear",intervalFacets.get(1).getBuckets().get(1).getLabel()); assertEquals("cm:created:[\"2016\" TO \"2017\">",intervalFacets.get(1).getBuckets().get(1).getFilterQuery()); assertEquals(METRIC_TYPE.count,((SimpleMetric) metrics[0]).getType()); assertEquals("0",((SimpleMetric) metrics[0]).getValue().get("count")); metrics = intervalFacets.get(1).getBuckets().get(2).getMetrics().toArray(); assertEquals("currentYear",intervalFacets.get(1).getBuckets().get(2).getLabel()); assertEquals("cm:created:[\"NOW/YEAR\" TO \"NOW/YEAR+1YEAR\"]",intervalFacets.get(1).getBuckets().get(2).getFilterQuery()); assertEquals(METRIC_TYPE.count,((SimpleMetric) metrics[0]).getType()); assertEquals("854",((SimpleMetric) metrics[0]).getValue().get("count")); }
Example #24
Source File: DbAftsQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ResultSet executeQuery(SearchParameters searchParameters) { if(metadataIndexCheck1.getPatchApplied()) { return super.executeQuery(searchParameters); } else { throw new QueryModelException("The patch to add the indexes to support in-transactional metadata queries has not been applied"); } }
Example #25
Source File: SearchApiWebscript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScriptResponse) throws IOException { try { //Turn JSON into a Java object respresentation SearchQuery searchQuery = extractJsonContent(webScriptRequest, assistant.getJsonHelper(), SearchQuery.class); //Parse the parameters Params params = getParams(webScriptRequest, searchQuery.getFields(), searchQuery.getInclude(), searchQuery.getPaging()); //Make a copy of the request SearchRequestContext searchRequestContext = SearchRequestContext.from(searchQuery); //Turn the SearchQuery json into the Java SearchParameters object SearchParameters searchParams = searchMapper.toSearchParameters(params, searchQuery, searchRequestContext); //Call searchService ResultSet results = searchService.query(searchParams); //Turn solr results into JSON CollectionWithPagingInfo<Node> resultJson = resultMapper.toCollectionWithPagingInfo(params, searchRequestContext, searchQuery, results); //Post-process the request and pass in params, eg. params.getFilter() Object toRender = helper.processAdditionsToTheResponse(null, null, null, params, resultJson); //Write response setResponse(webScriptResponse, DEFAULT_SUCCESS); renderJsonResponse(webScriptResponse, toRender, assistant.getJsonHelper()); } catch (Exception exception) { renderException(exception,webScriptResponse,assistant); } }
Example #26
Source File: ResultMapperTests.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Test /** * Test facet fields with out group label in the query. * This is to support original api methods query for facet query. * * * @throws Exception */ public void testFacetQueryWithoutGroupResponse() throws Exception { String jsonQuery = "{\"query\": {\"query\": \"alfresco\"}," + "\"facetQueries\": [" + "{\"query\": \"content.size:[0 TO 102400]\", \"label\": \"small\"}," + "{\"query\": \"content.size:[102400 TO 1048576]\", \"label\": \"medium\"}," + "{\"query\": \"content.size:[1048576 TO 16777216]\", \"label\": \"large\"}]" + "}"; String expectedResponse = "{\"responseHeader\":{\"status\":0,\"QTime\":9},\"_original_parameters_\":\"org.apache.solr.common.params.DefaultSolrParams:{params(df=TEXT&alternativeDic=DEFAULT_DICTIONARY&fl=DBID,score&start=0&fq={!afts}AUTHORITY_FILTER_FROM_JSON&fq={!afts}TENANT_FILTER_FROM_JSON&rows=1000&locale=en_US&wt=json),defaults(carrot.url=id&spellcheck.collateExtendedResults=true&carrot.produceSummary=true&spellcheck.maxCollations=3&spellcheck.maxCollationTries=5&spellcheck.alternativeTermCount=2&spellcheck.extendedResults=false&defType=afts&spellcheck.maxResultsForSuggest=5&spellcheck=false&carrot.outputSubClusters=false&spellcheck.count=5&carrot.title=mltext@m___t@{http://www.alfresco.org/model/content/1.0}title&carrot.snippet=content@s___t@{http://www.alfresco.org/model/content/1.0}content&spellcheck.collate=true)}\",\"_field_mappings_\":{},\"_date_mappings_\":{},\"_range_mappings_\":{},\"_pivot_mappings_\":{},\"_interval_mappings_\":{},\"_stats_field_mappings_\":{},\"_stats_facet_mappings_\":{},\"_facet_function_mappings_\":{},\"response\":{\"numFound\":6,\"start\":0,\"maxScore\":0.7849362,\"docs\":[{\"DBID\":565,\"score\":0.7849362},{\"DBID\":566,\"score\":0.7849362},{\"DBID\":521,\"score\":0.3540957},{\"DBID\":514,\"score\":0.33025497},{\"DBID\":420,\"score\":0.32440513},{\"DBID\":415,\"score\":0.2780319}]}," + "\"spellcheck\":{\"searchInsteadFor\":\"alfresco\"}," + "\"facet_counts\":{\"facet_queries\": {\"small\": 52,\"large\": 0,\"medium\": 0}}," + "\"processedDenies\":true, \"lastIndexedTx\":34}"; ResultSet results = mockResultset(expectedResponse); SearchQuery searchQuery = helper.extractFromJson(jsonQuery); SearchRequestContext searchRequest = SearchRequestContext.from(searchQuery); SearchContext searchContext = mapper.toSearchContext((SolrJSONResultSet) results, searchRequest, searchQuery, 0); assertEquals(34l, searchContext.getConsistency().getlastTxId()); assertTrue(searchContext.getFacets().isEmpty()); assertEquals(3,searchContext.getFacetQueries().size()); assertEquals("small",searchContext.getFacetQueries().get(0).getLabel()); assertEquals("content.size:[0 TO 102400]",searchContext.getFacetQueries().get(0).getFilterQuery()); assertEquals(52, searchContext.getFacetQueries().get(0).getCount()); assertEquals("large",searchContext.getFacetQueries().get(1).getLabel()); assertEquals("content.size:[1048576 TO 16777216]",searchContext.getFacetQueries().get(1).getFilterQuery()); assertEquals(0, searchContext.getFacetQueries().get(1).getCount()); assertEquals("medium",searchContext.getFacetQueries().get(2).getLabel()); assertEquals("content.size:[102400 TO 1048576]",searchContext.getFacetQueries().get(2).getFilterQuery()); assertEquals(0, searchContext.getFacetQueries().get(2).getCount()); }
Example #27
Source File: DbCmisQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private ResultSet executeQueryImpl(SearchParameters searchParameters) { CMISQueryOptions options = CMISQueryOptions.create(searchParameters); options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); CapabilityJoin joinSupport = CapabilityJoin.INNERANDOUTER; BaseTypeId[] validScopes = CmisFunctionEvaluationContext.ALFRESCO_SCOPES; CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext(); functionContext.setCmisDictionaryService(cmisDictionaryService); functionContext.setValidScopes(validScopes); CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport); org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new DBQueryModelFactory(), functionContext); // TODO: Remove as this appears to be dead code // // build lucene query // Set<String> selectorGroup = null; // if (queryModelQuery.getSource() != null) // { // List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext); // if (selectorGroups.size() == 0) // { // throw new UnsupportedOperationException("No selectors"); // } // if (selectorGroups.size() > 1) // { // throw new UnsupportedOperationException("Advanced join is not supported"); // } // selectorGroup = selectorGroups.get(0); // } // QueryEngineResults results = queryEngine.executeQuery(queryModelQuery, options, functionContext); ResultSet resultSet = results.getResults().values().iterator().next(); return resultSet; }
Example #28
Source File: DbCmisQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ResultSet executeQuery(SearchParameters searchParameters) { if(metadataIndexCheck1.getPatchApplied()) { return executeQueryImpl(searchParameters); } else { throw new QueryModelException("The patch to add the indexes to support in-transactional metadata queries has not been applied"); } }
Example #29
Source File: SolrSQLHttpClient.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected ResultSet postSolrQuery(HttpClient httpClient, String url, JSONObject body, SolrJsonProcessor<?> jsonProcessor) throws IOException, JSONException { JSONObject json = postQuery(httpClient, url, body); JSONResult results = jsonProcessor.getResult(json); LOGGER.debug("Sent : {}", url); LOGGER.debug("with: {}", body); LOGGER.debug("Got: {} in {} ms", results.getNumberFound(), results.getQueryTime()); return (ResultSet) results; }
Example #30
Source File: CMISResultSet.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public long getNumberFound() { for (ResultSet resultSet : wrapped.values()) { return resultSet.getNumberFound(); } throw new IllegalStateException(); }