Examples of SolrQuery


Examples of org.apache.solr.client.solrj.SolrQuery

      client.commit();
    }

    // Query the documents
    {
      SolrQuery query = new SolrQuery();
      query.setQuery("units_i:2");
      query.addSortField("value_i", SolrQuery.ORDER.asc);
      query.setRows(Integer.MAX_VALUE);

      QueryResponse response = client.query(query);
      SolrDocumentList results = response.getResults();
      Assert.assertEquals(results.getNumFound(), docCount / 10);
      for (int i = 0; i < results.size(); i++) {
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

      client.commit();
    }

    // Query the documents
    {
      SolrQuery query = new SolrQuery();
      query.setQuery("value_i:[* TO 9]");
      query.addSortField("value_i", SolrQuery.ORDER.asc);
      query.setRows(Integer.MAX_VALUE);

      QueryResponse response = client.query(query);
      SolrDocumentList results = response.getResults();
      Assert.assertEquals(results.getNumFound(), 10);
      for (int i = 0; i < results.size(); i++) {
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

    solr.add(docs);
    solr.commit();
    solr.optimize();
    //<start id="solrj-search-1"/>
    SolrQuery queryParams = new SolrQuery();//<co id="solrj-search.co.query"/>
    queryParams.setFields("description", "title");//<co id="solrj-search.co.fields"/>
    queryParams.setQuery("description:win OR description:all");//<co id="solrj-search.co.terms"/>
    queryParams.setRows(10);
    QueryResponse response = solr.query(queryParams);//<co id="solrj-search.co.process"/>
    assertTrue("response is null and it shouldn't be", response != null);
    SolrDocumentList documentList = response.getResults();
    System.out.println("Docs: " + documentList);
    assertTrue("response.getResults() Size: " + documentList.size() +
            " is not: " + 3, documentList.size() == 3);
    /*
<calloutlist>
    <callout arearefs="solrj-search.co.query"><para>A <classname>SolrQuery</classname> is a easy-to-use container for creating the most common types of queries.</para></callout>
    <callout arearefs="solrj-search.co.fields"><para>Set the names of the Fields to be returned in the documents.</para></callout>
    <callout arearefs="solrj-search.co.terms"><para>Set the terms to search.  The "OR" is a boolean operator which allows one or the other or both to be present in the query.</para></callout>
    <callout arearefs="solrj-search.co.process"><para>Submit the query to Solr and get back a <classname>QueryResponse</classname> which contains the results of the search.</para></callout>

</calloutlist>
*/
    //<end id="solrj-search-1"/>

    //<start id="solrj-search-dismax"/>
    queryParams.setQuery("lazy");
    queryParams.setParam("defType", "dismax");//<co id="solrj-search.co.dismax"/>
    queryParams.set("qf", "title^3 description^10");//<co id="sorlj-search.co.qf"/>
    System.out.println("Query: " + queryParams);
    response = solr.query(queryParams);
    assertTrue("response is null and it shouldn't be", response != null);
    documentList = response.getResults();
    assertTrue("documentList Size: " + documentList.size() +
            " is not: " + 2, documentList.size() == 2);
/*
<calloutlist>
    <callout arearefs="solrj-search.co.dismax"><para>Tell Solr to use the <classname>DisMax</classname> Query Parser (named dismax in solrconfig.xml). </para></callout>
    <callout arearefs="sorlj-search.co.qf"><para>The DisMax parser will search across the fields given by the "qf" parameter and boosts the terms accordingly.</para></callout>

</calloutlist>
*/
    //<end id="solrj-search-dismax"/>

    //<start id="solrj-search-facets"/>
    queryParams = new SolrQuery();
    queryParams.setQuery("description:number");
    queryParams.setRows(10);
    queryParams.setFacet(true);//<co id="solrj-search-facets-facetOn"/>
    queryParams.set("facet.field", "date");//<co id="solrj-search-facets-date"/>
    response = solr.query(queryParams);
    assertTrue("response is null and it shouldn't be", response != null);
    System.out.println("Query: " + queryParams);
    documentList = response.getResults();
    assertTrue("documentList Size: " + documentList.size() +
            " is not: " + 10, documentList.size() == 10);
    System.out.println("Facet Response: " + response.getResponse());//<co id="solrj-search-facets-print"/>
    /*
<calloutlist>
  <callout arearefs="solrj-search-facets-facetOn"><para>Turn on faceting for this query</para></callout>
  <callout arearefs="solrj-search-facets-date"><para>Specify the Field to facet on</para></callout>
  <callout arearefs="solrj-search-facets-print"><para>Print out the facet information</para></callout>

</calloutlist>
*/
    //<end id="solrj-search-facets"/>
    //<start id="solrj-search-more-like-this"/>
    queryParams = new SolrQuery();
    queryParams.setQueryType("/mlt");//<co id="solrj-search.co.mlt"/>
    queryParams.setQuery("description:number");
    queryParams.set("mlt.match.offset", "0");//<co id="solrj-search.co.mlt.off"/>
    queryParams.setRows(1);
    queryParams.set("mlt.fl", "description, title");//<co id="solrj-search.co.mlt.fl"/>
    response = solr.query(queryParams);
    assertTrue("response is null and it shouldn't be", response != null);
    SolrDocumentList results = (SolrDocumentList) response.getResponse().get("match");
    assertTrue("results Size: " + results.size() + " is not: " + 1,
            results.size() == 1);
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

          server.setMaxTotalConnections(100);
          server.setFollowRedirects(false);
          server.setAllowCompression(true);
          server.setMaxRetries(1);
        server.setRequestWriter(new BinaryRequestWriter());
        SolrQuery query = new SolrQuery();
        query.setParam("start", "0");
        if (newestPartion != null && !newestPartion.isEmpty()) {
          query.setParam(CommonParams.PARTION, newestPartion);
        }

       
        if(day!=null&&!day.isEmpty()&&!day.equals(newestPartion))
        {
          query.addFilterQuery("thedate:"+day);
        }
        query.setParam(CommonParams.HIGOHB,true);
        query.setParam("mlogtime", fmt.format(new Date()));

        query.setParam("rows", "0");
        query.setQuery("*:*");
        QueryResponse qr3 = server.query(query);
        SolrDocumentList result3 = qr3.getResults();
        if(result3!=null)
        {
          return result3.getNumFound();
        }else{
          SolrCore.log.info("checkSolrRecord result is null "+
            "http://localhost:" + port + context+"?"+query.toString());
        }
      } catch (SolrServerException e) {
        error = e;
        try {
          Thread.sleep(5000);
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

  }
  public static SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");

  public static SolrQuery makeSolrQuery(GetPartions.Shards shard)
  {
    SolrQuery query = new SolrQuery();
    query.setParam("showlog", "1");
    query.setParam(ShardParams.SHARDS, shard.urlShards);
    query.setParam(ShardParams.PARTIONS, shard.partions);

    query.setParam("mlogtime", fmt.format(new Date()));
    query.setParam(FacetParams.MERGER_MAX_SHARDS, String.valueOf(UniqConfig.getMaxMergerShard()));
    query.setParam(FacetParams.MERGER_SERVERS, shard.urlMSs);
    return query;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

 
 
  public MovieMatcher() throws MalformedURLException {
    solr = new CommonsHttpSolrServer(new URL("http://localhost:8983/solr"));
    query = new SolrQuery();
    query.setRows(10);
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

 
  public SpellCorrector(StringDistance sd, float threshold)
    throws MalformedURLException {
    solr = new CommonsHttpSolrServer(
            new URL("http://localhost:8983/solr"));
    query = new SolrQuery();
    query.setFields("word");
    query.setRows(50); //<co id="co.dym.num"/>
    this.sd = sd;
    this.threshold = threshold;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

  /**
   * A query that shows how to use a custom datatype (uri)
   */
  private SolrQuery getWebsiteQuery() {
    final SolrQuery query = new SolrQuery();
    query.setQuery("DeviceOwner : { Website : uri(www.sourcelondon.net) }");
    return query;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

  /**
   * A query that shows how to use range query on geo-location data (double)
   */
  private SolrQuery getGeoQuery() {
    final SolrQuery query = new SolrQuery();
    query.setQuery("ChargeDeviceLocation : { " +
        "Latitude : xsd:double([52 TO 53]), " +
        "Longitude : xsd:double([-2 TO 2]) " +
        "}");
    return query;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.SolrQuery

  /**
   * A query that shows how to use range query on long numeric value
   */
  private SolrQuery getOutputCurrentQuery() {
    final SolrQuery query = new SolrQuery();
    query.setQuery("(ChargeDeviceLocation : { " +
        "Latitude : xsd:double([52 TO 53]), " +
        "Longitude : xsd:double([-2 TO 2]) " +
        "}) AND " +
        "(Connector : [ { RatedOutputCurrent : xsd:long([32 TO *]) } ])");
    return query;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.