query.setParam("fq", "id:[ " + startkey + " TO * ]"); if (returnFields) { query.setFields(fieldList);
query.setParam("fq", "id:[ " + startkey + " TO * ]"); if (returnFields) { query.setFields(fieldList);
solrQuery.setParam(CursorMarkParams.CURSOR_MARK_PARAM, stateMap.get(STATE_MANAGER_CURSOR_MARK)); solrQuery.setRows(context.getProperty(BATCH_SIZE).asInteger()); .append(id_field) .append(" asc"); solrQuery.setParam("sort", sortClause.toString()); final String newCursorMark = response.getNextCursorMark(); solrQuery.setParam(CursorMarkParams.CURSOR_MARK_PARAM, newCursorMark); stateMap.put(STATE_MANAGER_CURSOR_MARK, newCursorMark); stateMap.put(STATE_MANAGER_FILTER, latestDateValue);
protected void setParameters ( SolrQuery squery ) { // Create a proper String with default fields to search StringBuilder defaults = new StringBuilder ( ) ; for ( String field : defaultFields ){ defaults .append ( field ) .append ( " " ) ; } // Use dismax parser for querying default fields squery.setParam ( DISMAX_PARAM_NAME, defaults .toString ( ) ); // Set the query type parameters such as a dismax type squery.setParam ( QUERY_TYPE, DISMAX_TYPE ) ; // Set the default MM parameter with one squery.setParam ( DEFAULT_MM_PARAM, "1" ) ; }
private static void setDefaults(SolrQuery solrQuery, OakSolrConfiguration configuration) { solrQuery.setParam("q.op", "AND"); solrQuery.setParam("fl", configuration.getPathField() + " score"); String catchAllField = configuration.getCatchAllField(); if (catchAllField != null && catchAllField.length() > 0) { solrQuery.setParam("df", catchAllField); } solrQuery.setParam("rows", String.valueOf(configuration.getRows())); }
private static void setDefaults(SolrQuery solrQuery, OakSolrConfiguration configuration) { solrQuery.setParam("q.op", "AND"); solrQuery.setParam("fl", configuration.getPathField() + " score"); String catchAllField = configuration.getCatchAllField(); if (catchAllField != null && catchAllField.length() > 0) { solrQuery.setParam("df", catchAllField); } solrQuery.setParam("rows", String.valueOf(configuration.getRows())); }
/** * A query that shows how to use the nested query parameter to use Solr's * query parsers on Solr's fields. */ private SolrQuery getNestedQuery() { final SolrQuery query = new SolrQuery(); query.setQuery("DeviceOwner : { Website : uri(www.sourcelondon.net) }"); query.setParam("nested", "{!lucene} name:university"); return query; }
SolrQuery query = new SolrQuery(); query.setQuery( "lastName:konov" ); query.setParam("fq", "location:Russia OR location:USA");
/** get a deep copy of this object **/ public SolrQuery getCopy() { SolrQuery q = new SolrQuery(); for (String name : this.getParameterNames()) { q.setParam(name, this.getParams(name)); } return q; }
/** get a deep copy of this object **/ public SolrQuery getCopy() { SolrQuery q = new SolrQuery(); for (String name : this.getParameterNames()) { q.setParam(name, this.getParams(name)); } return q; }
/** get a deep copy of this object **/ public SolrQuery getCopy() { SolrQuery q = new SolrQuery(); for (String name : this.getParameterNames()) { q.setParam(name, this.getParams(name)); } return q; }
@Override public SolrQuery doConstructSolrQuery(TermsQuery query, @Nullable Class<?> domainType) { Assert.notNull(query, "Cannot construct solrQuery from null value."); SolrQuery solrQuery = new SolrQuery(); String queryString = getQueryString(query, domainType); if (StringUtils.hasText(queryString)) { solrQuery.setParam(CommonParams.Q, queryString); } appendTermsOptionsToSolrQuery(query.getTermsOptions(), solrQuery); processTermsFields(solrQuery, query); appendRequestHandler(solrQuery, query.getRequestHandler()); return solrQuery; }
/** * A query that shows how to use the nested query parameter to use Solr's * query parsers on Solr's fields. */ private SolrQuery getNestedQuery() throws QueryNodeException { ConciseQueryBuilder b = new ConciseQueryBuilder(); String q = b.newTwig("DeviceOwner") .with(b.newNode("uri(www.sourcelondon.net)").setAttribute("Website")) .toString(); final SolrQuery query = new SolrQuery(); query.setQuery(q); query.setParam("nested", "{!lucene} ChargeDeviceName:university"); return query; }
@Test public void testCurlyBracketInNestedQuery() throws IOException, SolrServerException { this.addJsonString("1", "{ \"aaa\" : { \"bbb\" : \"ccc\" } }"); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!keyword} aaa : { bbb : ccc } "); query.setRequestHandler("keyword"); String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length); query = new SolrQuery(); query.setParam("nested", "{!tree} { \"node\" : { \"query\" : \"ccc\" } }"); query.setRequestHandler("keyword"); results = this.search(query, ID_FIELD); assertEquals(1, results.length); }
@Test public void testEmptyMainQueryWithNestedMatchAll() throws IOException, SolrServerException { this.addJsonString("1", "{ \"aaa\" : \"bbb\" }"); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} *:*"); query.setRequestHandler("keyword"); String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length); }
/** * Test the null field type. The path aaa.bbb is configured with the null field type which indicates to ignore the * field. Therefore the field 'aaa.bbb' should not be indexed and the search should throw an exception. */ @Test(expected=SolrException.class) public void testNullMapper() throws QueryNodeException, IOException, SolrServerException { String input = "{ \"id\" : \"1\", \"aaa\" : { \"bbb\" : \"ccc\" } }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} aaa.bbb:ccc"); query.setRequestHandler("tree"); this.search(query); }
/** * When no local parameters are defined, then it should rely on the default * solr parser (i.e., lucene). */ @Test public void testNoLocalParamater() throws IOException, SolrServerException { this.addJsonString("1", "{ \"aaa\" : \"bbb\" }"); final SolrQuery query = new SolrQuery(); query.setQuery("aaa : bbb"); query.setParam("nested", URL_FIELD + ":1"); query.setRequestHandler("keyword"); final String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length); }
/** * When no local parameters are defined, then it should rely on the default * solr parser (i.e., lucene). */ @Test public void testNoLocalParamater() throws IOException, SolrServerException { this.addJsonString("1", "{ \"aaa\" : \"bbb\" }"); final SolrQuery query = new SolrQuery(); query.setQuery("aaa : bbb"); query.setParam("nested", URL_FIELD + ":1"); query.setRequestHandler("keyword"); final String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length); }
/** * Check that the special SIREn's object for datatype is properly flattened. */ @Test public void testDatatypeObject() throws QueryNodeException, IOException, SolrServerException { String input = "{ \"id\" : \"1\", \"aaa\" : null, \"bbb\" : { \"_datatype_\" : \"uri\", \"_value_\" : \"ccc\" } }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb:ccc"); query.setRequestHandler("tree"); long found = this.search(query).getNumFound(); assertEquals(1, found); }