Examples of SolrInputDocument


Examples of org.apache.solr.common.SolrInputDocument

    }

    @Test
    public void testInsertSolrInputDocumentAsXMLWithoutAddRoot() throws Exception {

        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "MA147LL/A", 1.0f);
        String docAsXml = ClientUtils.toXML(doc);
        template.sendBodyAndHeader("direct:start", docAsXml, SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
        solrCommit();

        QueryResponse response = executeSolrQuery("id:MA147LL/A");
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    }

    @Test
    public void testInsertSolrInputDocumentAsXMLWithAddRoot() throws Exception {

        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "MA147LL/A", 1.0f);
        String docAsXml = "<add>" + ClientUtils.toXML(doc) + "</add>";
        template.sendBodyAndHeader("direct:start", docAsXml, SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
        solrCommit();

        QueryResponse response = executeSolrQuery("id:MA147LL/A");
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    }

    @Test
    public void testInsertSolrInputDocument() throws Exception {

        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "MA147LL/A", 1.0f);
        template.sendBodyAndHeader("direct:start", doc, SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);

        solrCommit();

        QueryResponse response = executeSolrQuery("id:MA147LL/A");
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

   * @throws SearchServiceException
   */
  public void index(VisualizationGraphNode node) throws SolrServerException,
      IOException, NoSuchAlgorithmException {

    SolrInputDocument doc1 = new SolrInputDocument();
    // Save our basic info that we already have
 
    doc1.addField("type", node.getType());
   
    doc1.addField("a", node.getA());
    doc1.addField("b", node.getB());
   
    doc1.addField("a_auth", node.getA_auth());   
    doc1.addField("b_auth", node.getB_auth());
   
    doc1.addField("a_dept", node.getA_dept());       
        doc1.addField("b_dept", node.getB_dept());
        doc1.addField("focus_dept", node.getA_dept()+"|||"+node.getB_dept());
       
    doc1.addField("a_val", node.getFavalue());   
    doc1.addField("b_val", node.getFbvalue());
   
    doc1.addField("value", node.getValue());
    doc1.addField("entity", node.getEntity());
    doc1.addField("extra", node.getExtra());
    try {
        log.debug("add document on solr index " + node.getA() + "|||" + node.getB());
      getSolr().add(doc1);
    }
    catch(Exception e) {
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    public <P extends Property<TP>, TP extends PropertiesDefinition, NP extends ANestedProperty<NTP>, NTP extends ANestedPropertiesDefinition, ACNO extends ACrisNestedObject<NP, NTP, P, TP>, ATNO extends ATypeNestedObject<NTP>> boolean indexCrisObject(
            ACrisObject<P, TP, NP, NTP, ACNO, ATNO> dso, boolean b)
    {
        boolean result = false;
        SolrInputDocument doc = buildDocument(dso.getType(), dso.getID(), null,
                null);

        log.debug("Building Cris: " + dso.getUuid());

        String schema = "cris" + dso.getPublicPath();
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    public <P extends Property<TP>, TP extends PropertiesDefinition, NP extends ANestedProperty<NTP>, NTP extends ANestedPropertiesDefinition, ACNO extends ACrisNestedObject<NP, NTP, P, TP>, ATNO extends ATypeNestedObject<NTP>> boolean indexNestedObject(
            ACNO dso, boolean b)
    {
        boolean result = false;
        SolrInputDocument doc = buildDocument(dso.getType(), dso.getID(), null,
                null);

        log.debug("Building Cris: " + dso.getUuid());

        ICrisObject<P, TP> parent = (ICrisObject<P, TP>) dso.getParent();
        doc.addField("search.parentfk", parent.getType() + "-" + parent.getID());
        String confName = "ncris" + parent.getPublicPath();
        String schema = confName + dso.getTypo().getShortName();
        String uuid = dso.getUuid();
        Boolean status = dso.getStatus();
        Integer position = dso.getPositionDef();
        doc.addField("position", position);
        commonIndexerHeader(status, uuid, doc);

        // Keep a list of our sort values which we added, sort values can only
        // be added once
        List<String> sortFieldsAdded = new ArrayList<String>();
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

        for (SolrDocument sd : sdl)
        {
            i++;
            System.out.println("Processed access #" + i + " of "
                    + sdl.getNumFound());
            SolrInputDocument sdi = ClientUtils.toSolrInputDocument(sd);
            Integer id = (Integer) sd.getFieldValue("id");
            Integer type = (Integer) sd.getFieldValue("type");

            DSpaceObject dso = DSpaceObject.find(context, type, id);
           
            // Do any additional indexing, depends on the plugins
            List<SolrStatsIndexPlugin> solrServiceIndexPlugins = new DSpace()
                    .getServiceManager().getServicesByType(
                            SolrStatsIndexPlugin.class);
            for (SolrStatsIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins)
            {
                solrServiceIndexPlugin.additionalIndex(null, dso,
                        sdi);
            }

           
            context.removeCached(dso, id);
            solr.add(sdi);
        }
        solr.commit();
        solr.optimize();

        sdl = indexer.getRawData(CrisConstants.RP_TYPE_ID);
        System.out.println("Found " + sdl.getNumFound()
                + " access in the RP statistics core");
        HttpSolrServer rpsolr = indexer.getSolr();
        indexer.deleteByType(CrisConstants.RP_TYPE_ID);
        rpsolr.commit();

        System.out.println("Remove old data");
       
        ApplicationService as = dspace.getServiceManager().getServiceByName(
                "applicationService", ApplicationService.class);
        i = 0;
        for (SolrDocument sd : sdl)
        {
            i++;
            System.out.println("Processed RP access #" + i + " of "
                    + sdl.getNumFound());
            SolrInputDocument sdi = ClientUtils.toSolrInputDocument(sd);
            Integer id = (Integer) sd.getFieldValue("id");

            ResearcherPage rp = as.get(ResearcherPage.class, id);
            if (rp == null)
                continue;
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

     * @return SolrInputDocument: The prepared document
     */
    private SolrInputDocument createSolrDoc(String[] row) {
        float boost = 1.0f;

        SolrInputDocument doc = new SolrInputDocument();
        for (String key : columns.keySet()) {
          if(columnsToExclude.contains(key)) {
            continue;
          }
           
            String data = get(row, key);
            // Fix dates
            if (key.equals("date_modified")) {
                data += "T00:00:00Z";
            }
            // Sometimes the geonames 'asciiname' is empty
            if (key.equals("basic_name")) {
                if (empty(data)) {
                    data = get(row, "utf8_name");
                    //log.warn("{}: ASCII Name missing," +
                    //       " using UTF-8 version: '{}'", now(), data);
                }
                // We need a 'string' version, and a reversed thereof
                String string = data.toLowerCase();
                doc.addField("basic_name_str", string);
                String rev = new StringBuffer(string).reverse().toString();
                doc.addField("basic_name_rev", rev);
            }
            // Boost some countries
            if (countryIdsToBoost != null && key.equals("country_code")) {
                if (countryIdsToBoost.contains(data)) {
                    boost *= 5;
                }
            }
            // Boost populated locations
            if (key.equals("feature_code")) {
                if (data.startsWith("PPL")) {
                    boost *= 2;
                }
            }
            if (!empty(data)) {
                doc.addField(key, data);
            }
        }
        // We are placing the boost on a field that all records have the same
        //  value in. Then add 'AND boost:boost' to all queries.
        doc.addField("boost", "boost", boost);
        return doc;
    }
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    commitSize = job.getInt(SolrConstants.COMMIT_SIZE, 1000);
    solrMapping = SolrMappingReader.getInstance(job);
  }

  public void write(NutchDocument doc) throws IOException {
    final SolrInputDocument inputDoc = new SolrInputDocument();
    for(final Entry<String, NutchField> e : doc) {
      for (final Object val : e.getValue().getValues()) {
        inputDoc.addField(solrMapping.mapKey(e.getKey()), val, e.getValue().getWeight());
        String sCopy = solrMapping.mapCopyKey(e.getKey());
        if (sCopy != e.getKey()) {
          inputDoc.addField(sCopy, val, e.getValue().getWeight())
        }
      }
    }
    inputDoc.setDocumentBoost(doc.getWeight());
    inputDocs.add(inputDoc);
    if (inputDocs.size() > commitSize) {
      try {
        solr.add(inputDocs);
      } catch (final SolrServerException e) {
View Full Code Here

Examples of org.apache.solr.common.SolrInputDocument

    solrMapping = SolrMappingReader.getInstance(conf);
  }

  @Override
  public void write(NutchDocument doc) throws IOException {
    final SolrInputDocument inputDoc = new SolrInputDocument();
    for(final Entry<String, List<String>> e : doc) {
      for (final String val : e.getValue()) {

        Object val2 = val;
        if (e.getKey().equals("content")) {
          val2 = stripNonCharCodepoints((String)val);
        }

        inputDoc.addField(solrMapping.mapKey(e.getKey()), val2);
        String sCopy = solrMapping.mapCopyKey(e.getKey());
        if (sCopy != e.getKey()) {
          inputDoc.addField(sCopy, val2);
        }
      }
    }
    inputDoc.setDocumentBoost(doc.getScore());
    inputDocs.add(inputDoc);
    if (inputDocs.size() >= commitSize) {
      try {
        LOG.info("Adding " + Integer.toString(inputDocs.size()) + " documents");
        solr.add(inputDocs);
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.