Examples of SolrInputDocument


Examples of org.apache.solr.common.SolrInputDocument

        if (isEmpty() || contains(key)) solrdoc.setField(key, value, boost);
    }

    public SolrInputDocument yacy2solr(final String id, final ResponseHeader header, final Document yacydoc) {
        // we user the SolrCell design as index scheme
        final SolrInputDocument solrdoc = new SolrInputDocument();
        final DigestURI digestURI = new DigestURI(yacydoc.dc_source());
        addSolr(solrdoc, "failreason_t", ""); // overwrite a possible fail reason (in case that there was a fail reason before)
        addSolr(solrdoc, "id", id);
        addSolr(solrdoc, "sku", digestURI.toNormalform(true, false), 3.0f);
        final InetAddress address = Domains.dnsResolve(digestURI.getHost());
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

        }
    }

    public void err(final DigestURI digestURI, final String failReason, final int httpstatus) throws IOException {

            final SolrInputDocument solrdoc = new SolrInputDocument();
            solrdoc.addField("id", ASCII.String(digestURI.hash()));
            solrdoc.addField("sku", digestURI.toNormalform(true, false), 3.0f);
            final InetAddress address = Domains.dnsResolve(digestURI.getHost());
            if (address != null) solrdoc.addField("ip_s", address.getHostAddress());
            if (digestURI.getHost() != null) solrdoc.addField("host_s", digestURI.getHost());

            // path elements of link
            final String path = digestURI.getPath();
            if (path != null) {
                final String[] paths = path.split("/");
                if (paths.length > 0) solrdoc.addField("attr_paths", paths);
            }

            solrdoc.addField("failreason_t", failReason);
            solrdoc.addField("httpstatus_i", httpstatus);

            add(solrdoc);
    }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

            if (hasSolrHeaders) {

                UpdateRequest updateRequest = new UpdateRequest(getRequestHandler());

                SolrInputDocument doc = new SolrInputDocument();
                for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
                    if (entry.getKey().startsWith(SolrConstants.FIELD)) {
                        String fieldName = entry.getKey().substring(SolrConstants.FIELD.length());
                        doc.setField(fieldName, entry.getValue());
                    }
                }
                updateRequest.add(doc);
                updateRequest.process(solrServer);
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    int docCount = 1000;

    // Add some documents
    {
      for (int i = 0; i < docCount; i++) {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", i);
        doc.addField("name_t", "document" + i);
        doc.addField("value_i", i);
        doc.addField("units_i", i % 10);
        doc.addField("content_t", random.randomText(40, 2000));
        client.add(doc);
      }

      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++) {
        SolrDocument doc = results.get(i);

        int docId = (i * 10) + 2;
        Assert.assertEquals(doc.get("id"), String.valueOf(docId));
        Assert.assertEquals(doc.get("units_i"), 2);
        Assert.assertEquals(doc.get("name_t"), "document" + docId);
      }
    }
  }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    List<String> fieldValues = Lists.newArrayList();

    // Add some documents
    {
      for (int i = 0; i < docCount; i++) {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", i);
        doc.addField("value_i", i);

        String fieldValue = random.randomText(40, 2000);
        doc.addField(field, fieldValue);
        fieldValues.add(fieldValue);

        client.add(doc);
      }

      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++) {
        SolrDocument doc = results.get(i);

        int docId = i;
        Assert.assertEquals(doc.get("id"), String.valueOf(docId));
        Assert.assertEquals(doc.get("value_i"), docId);
        Assert.assertEquals(doc.get(field), fieldValues.get(i));
      }
    }
  }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

   
  @Override
  public synchronized void expire(BoltStatKey key, BoltStatVal val) {
    try{
      this.committs=val.getGroupts();
     SolrInputDocument doc=new SolrInputDocument();

    String[] groupnames=parse.getGroupName();
    for(int i=0;i<groupnames.length&&i<key.list.length;i++)
    {
        doc.addField(groupnames[i], key.list[i]);
    }
   
    String[] statNames=parse.getSumName();

    for(int i=0;i<statNames.length&&i<val.list.length;i++)
    {
        doc.addField(statNames[i], val.list[i]);
    }
 
      boolean needCommit=false;

      synchronized (doclistLock) {
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

            }
  }
 
    public Document convert(java.util.Map<String, String> value) {

      SolrInputDocument doc = new SolrInputDocument();
      for (Entry<String, String> e : value.entrySet()) {
    String fieldName = e.getKey();
    String fieldValue = e.getValue();
    doc.addField(fieldName, fieldValue);
      }

      return DocumentBuilder.toDocument(doc, this.schema);
 
    }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

      long ts=log.getTs();
    BoltStatKey key=new BoltStatKey(log.getGroup());
    BoltStatVal val=new BoltStatVal(log.getSum(),ts);
   
   
    SolrInputDocument doc=new SolrInputDocument();

    String[] groupnames=parse.getGroupName();
    for(int i=0;i<groupnames.length&&i<key.list.length;i++)
    {
        doc.addField(groupnames[i], key.list[i]);
    }
   
    String[] statNames=parse.getSumName();

    for(int i=0;i<statNames.length&&i<val.list.length;i++)
    {
        doc.addField(statNames[i], val.list[i]);
    }
   
    System.out.println(doc.toString());
      return true;
  }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    BoltStatVal val=new BoltStatVal(log.getSum(),ts);
   
    this.status.ttInput++;
    this.status.groupCreate++;
   
    SolrInputDocument doc=new SolrInputDocument();

    String[] groupnames=parse.getGroupName();
    for(int i=0;i<groupnames.length&&i<key.list.length;i++)
    {
        doc.addField(groupnames[i], key.list[i]);
    }
   
    String[] statNames=parse.getSumName();

    for(int i=0;i<statNames.length&&i<val.list.length;i++)
    {
        doc.addField(statNames[i], val.list[i]);
    }
   
    synchronized (doclistLock) {
      doclist.add(doc);
    }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

            "all too familiar scene in sporting events today.  " +
            "Fans everywhere were appalled by the revelations, with " +
            "allegiances falling roughly along species lines.";
    //<start id="solrj"/>
    SolrServer solr = new CommonsHttpSolrServer(new URL("http://localhost:" + port + "/solr"));//<co id="co.solrj.server"/>
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", "http://tortoisehare5k.tamingtext.com");//<co id="co.solrj.unique"/>
    doc.addField("mimeType", "text/plain");
    doc.addField("title", "Tortoise beats Hare!  Hare wants rematch.", 5);//<co id="co.solrj.title"/>
    Date now = new Date();
    doc.addField("date", DateUtil.getThreadLocalDateFormat().format(now));//<co id="co.solrj.date"/>
    doc.addField("description", description);
    doc.addField("categories_t", "Fairy Tale, Sports");//<co id="co.solrj.dynamic.field"/>
    solr.add(doc);//<co id="co.solrj.add"/>
    solr.commit();//<co id="co.solrj.commit"/>
    /*
    <calloutlist>
    <callout arearefs="co.solrj.server"><para>Create a HTTP-based Solr Server connection.</para></callout>
      <callout arearefs="co.solrj.unique"><para>The schema used for this instance of Solr requires a unique field named "id"</para></callout>
      <callout arearefs="co.solrj.title"><para>Add a Title field to our document and boost it to be 5 times as important as the other fields</para></callout>
      <callout arearefs="co.solrj.date"><para>Dates must be formatted in a specific way for Solr.</para></callout>
      <callout arearefs="co.solrj.dynamic.field"><para>A dynamic field allows for the addition of unknown fields to Solr.  The "_t" tells Solr this should be treated as a text field.</para></callout>
      <callout arearefs="co.solrj.add"><para>Send the newly created document to Solr.  Solr takes care of creating a correctly formatted XML message and sending it to Solr using Apache Jakarta Commons HTTPClient.</para></callout>
      <callout arearefs="co.solrj.commit"><para>After you have added all your documents and wish to make them available for searching, send a commit message to Solr</para></callout>
    </calloutlist>
    */
    //<end id="solrj"/>
    //Add some more docs
    doc = new SolrInputDocument();//<co id="co.solrj.doc"/>
    doc.addField("id", "http://redfox.tamingtext.com");//<co id="co.solrj.unique"/>
    doc.addField("mimeType", "text/plain");//<co id="co.solrj.mime"/>
    doc.addField("title", "Red Fox mocks Lazy Brown Dogs!", 5);//<co id="co.solrj.title"/>
    now = new Date();
    doc.addField("date", DateUtil.getThreadLocalDateFormat().format(now));
    doc.addField("description", "Once again, the Red Fox outshined the" +
            " lazy Brown Dogs to win the vaunted Tally Ho Cup, in what" +
            " has become an annual ritual.  The lazy brown " +
            "dogs just don't seem to have the drive that Red Fox does." +
            "  The lazy Brown Dogs vow to avenge their latest defeat, " +
            "but the group's supporters claim to have heard it all before.");
    doc.addField("categories_t", "Fairy Tale, Sports");
    solr.add(doc);//<co id="co.solrj.add"/>
    doc = new SolrInputDocument();//<co id="co.solrj.doc"/>
    doc.addField("id", "http://maryLambs.tamingtext.com");//<co id="co.solrj.unique"/>
    doc.addField("mimeType", "text/plain");//<co id="co.solrj.mime"/>

    now = new Date(10000);
    doc.addField("date", DateUtil.getThreadLocalDateFormat().format(now));
    doc.addField("title", "Mary's Little Lamb Stolen!.", 5);//<co id="co.solrj.title"/>
    doc.addField("description", "In an affront to all that is good and" +
            " decent in this world, criminals made off with Mary's " +
            "little Lamb in a late night raid on Mary's farm." +
            "  Early suspects include a Ms. Bo Peep who weeks earlier " +
            "reported losing several sheep.  Police suspect Ms. Peep " +
            "was going to use the lamb to bring her flock's numbers back up." +
            "  The spokesman for Ms. Peep declined comment at this " +
            "time.  Mary, however, was outraged and promises revenge " +
            "on the insensitive clod who stole her precious animals.");
    doc.addField("categories_t", "Fairy Tale, crime, sheep");
    solr.add(doc);
    //add in some random other docs
    Collection<SolrInputDocument> docs = new HashSet<SolrInputDocument>();
    for (int i = 0; i < 100; i++) {
      doc = new SolrInputDocument();
      doc.addField("id", "http://www.tamingtext.com/" + i + ".html");
      doc.addField("mimeType", "text/html");
      doc.addField("title", "This is title " + i);
      now = new Date(150 * i + i + 20);//create some dates
      doc.addField("date", DateUtil.getThreadLocalDateFormat().format(now));
      doc.addField("description", "This is description number: " + i
              + " of something that is very important.");
      docs.add(doc);
    }

    solr.add(docs);
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.