Exemplo n.º 1
0
  public static void indexTable(
      SecureTable t, DboTableMeta tableMeta, Collection<SolrInputDocument> solrDocs)
      throws IOException, SAXException, ParserConfigurationException, SolrServerException {
    // Solr server instance
    SolrServer solrServer = Search.getSolrServer();
    // Add this new table to the meta index...
    createCoreIfNeeded("databusmeta", "databusmeta", solrServer);
    SolrInputDocument doc = new SolrInputDocument();

    // Add special fields to track the type of record an the primary
    // key.
    doc.addField("id", t.getTableName());
    doc.addField("type", "table");
    if (t.getCreator() != null) doc.addField("creator_texts", t.getCreator().getUsername());
    doc.addField("description_texts", t.getDescription());
    if (t.getSchema() != null) {
      doc.addField("database_texts", t.getSchema().getSchemaName());
      doc.addField("databaseDescription_texts", t.getSchema().getDescription());
    }
    if (t.isSearchable()) doc.addField("isSearchable_texts", "true");
    else doc.addField("isSearchable_texts", "false");

    Set<String> allTermsSet = new HashSet<String>();
    Set<String> columnsSet = new HashSet<String>();

    for (DboColumnMeta m : tableMeta.getAllColumns()) {
      SdiColumn sdicol = t.getNameToField().get(m.getColumnName());
      columnsSet.add(sdicol.getColumnName());
    }

    doc.addField("column_texts", columnsSet);

    allTermsSet.add((String) doc.getField("id").getValue());
    allTermsSet.add((String) doc.getField("type").getValue());
    allTermsSet.add((String) doc.getField("description_texts").getValue());

    allTermsSet.addAll(columnsSet);
    if (doc.getField("database_texts") != null) {
      allTermsSet.add((String) doc.getField("database_texts").getValue());
      allTermsSet.add((String) doc.getField("databaseDescription_texts").getValue());
    }
    doc.addField("allTerms_texts", allTermsSet);

    solrDocs.add(doc);
    // Create the core for data from this table to be indexed into when data is posted to this table
    if (t.isSearchable()) createCoreIfNeeded(t.getTableName(), t.getTableName(), solrServer);
  }
Exemplo n.º 2
0
  public static void indexAggregation(StreamAggregation aggregation, SecureSchema owningSchema)
      throws IOException, SAXException, ParserConfigurationException, SolrServerException {
    // Solr server instance
    SolrServer solrServer = Search.getSolrServer();
    // Add this new table to the meta index...
    createCoreIfNeeded("databusmeta", "databusmeta", solrServer);
    SolrInputDocument doc = new SolrInputDocument();

    // Add special fields to track the type of record an the primary key.
    doc.addField("id", aggregation.getName());
    doc.addField("type", "aggregation");
    // aggregations don't store their creator.  Add something like this later
    // doc.addField("creator_texts", aggregation.getCreator().getUsername());

    doc.addField("description_texts", aggregation.getUrls());

    // There is a bug in the 2 way relationship between aggs and schemas, right now it's possible
    // for a
    // schema to have an aggregation in it's 'getAggregations()' list, but the aggregation DOES NOT
    // HAVE
    // that schema set as it's .getSchema().  It's possible to pass in the owning schema to account
    // for this.
    if (aggregation.getSchema() != null) {
      doc.addField("database_texts", aggregation.getSchema().getSchemaName());
      doc.addField("databaseDescription_texts", aggregation.getSchema().getDescription());
    } else if (owningSchema != null) {
      doc.addField("database_texts", owningSchema.getSchemaName());
      doc.addField("databaseDescription_texts", owningSchema.getDescription());
    }

    Set<String> allTermsSet = new HashSet<String>();

    allTermsSet.add((String) doc.getField("id").getValue());
    allTermsSet.add((String) doc.getField("type").getValue());
    allTermsSet.addAll(aggregation.getUrls());

    if (aggregation.getSchema() != null && owningSchema != null) {
      allTermsSet.add((String) doc.getField("database_texts").getValue());
      allTermsSet.add((String) doc.getField("databaseDescription_texts").getValue());
    }

    doc.addField("allTerms_texts", allTermsSet);

    UpdateRequest request = new UpdateRequest();
    request.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);
    request.add(doc);
    request.process(Search.getSolrCore("databusmeta"));
  }
Exemplo n.º 3
0
  public static void indexSchema(SecureSchema theSchema)
      throws IOException, SAXException, ParserConfigurationException, SolrServerException {
    // Solr server instance
    SolrServer solrServer = Search.getSolrServer();
    // Add this new table to the meta index...
    createCoreIfNeeded("databusmeta", "databusmeta", solrServer);
    SolrInputDocument doc = new SolrInputDocument();

    // Add special fields to track the type of record an the primary
    // key.
    doc.addField("id", theSchema.getSchemaName());
    doc.addField("type", "database");
    if (theSchema.getCreator() != null)
      doc.addField("creator_texts", theSchema.getCreator().getUsername());
    doc.addField("description_texts", theSchema.getDescription());
    doc.addField("database_texts", theSchema.getSchemaName());
    doc.addField("databaseDescription_texts", theSchema.getDescription());

    Set<String> allTermsSet = new HashSet<String>();

    allTermsSet.add((String) doc.getField("id").getValue());
    allTermsSet.add((String) doc.getField("type").getValue());
    allTermsSet.add((String) doc.getField("description_texts").getValue());

    allTermsSet.add((String) doc.getField("database_texts").getValue());

    doc.addField("allTerms_texts", allTermsSet);

    UpdateRequest request = new UpdateRequest();
    request.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);
    request.add(doc);
    request.process(Search.getSolrCore("databusmeta"));
    List<StreamAggregation> aggregations = theSchema.getAggregations();
    for (StreamAggregation agg : aggregations) {
      indexAggregation(agg, theSchema);
    }
  }