Innovative Tech Consulting

Contact UsView Openings

HTML5 – New Media Elements

HTML5 offers new elements for media content:

Tag Description
<audio> Defines sound content
<video> Defines a video or movie
<source> Defines multiple media resources for <video> and <audio>
<embed> Defines a container for an external application or interactive content (a plug-in)
<track> Defines text tracks for <video> and <audio>

Which is one of the biggest advantage of HTML5. Back in the days if you had to insert audio or video content, you used Flash content. Now HTML5 has advanced elements that you can insert your video and audio contents within your HTML page without any flash or other plugins.

In my next article, I will cover both Audio and Video elements. I will have sample HTML5 code for the tags and related information.

Important thing to note here, all media formats are not supported by all browsers. You need to make sure to have appropriate media file formats available if you want to serve your content in all available browsers.

Let us know your feedback or comments about this article.

HTML5 – New Elements

HTML5 offers new elements for better structure:

Tag Description
<article> Defines an article
<aside> Defines content aside from the page content
<bdi> Isolates a part of text that might be formatted in a different direction from other text outside it
<command> Defines a command button that a user can invoke
<details> Defines additional details that the user can view or hide
<summary> Defines a visible heading for a <details> element
<figure> Specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
<figcaption> Defines a caption for a <figure> element
<footer> Defines a footer for a document or section
<header> Defines a header for a document or section
<hgroup> Groups a set of <h1> to <h6> elements when a heading has multiple levels
<mark> Defines marked/highlighted text
<meter> Defines a scalar measurement within a known range (a gauge)
<nav> Defines navigation links
<progress> Represents the progress of a task
<ruby> Defines a ruby annotation (for East Asian typography)
<rt> Defines an explanation/pronunciation of characters (for East Asian typography)
<rp> Defines what to show in browsers that do not support ruby annotations
<section> Defines a section in a document
<time> Defines a date/time
<wbr> Defines a possible line-break

 

Data Import Handler in SOLR

Index a DB table directly into Solr

Step 1 : Edit your solrconfig.xml to add the request handler

<requestHandler name="/dataimport">
<lst name="defaults">
  <str name="config">data-config.xml</str>
</lst>
</requestHandler>

Step 2 : Create a data-config.xml file as follows and save it to the conf dir

 

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/dbname" 
              user="user-name" 
              password="password"/>
  <document>
    <entity name="id" 
            query="select id,name,desc from mytable">
    </entity>
  </document>
</dataConfig>

Step 3 : Ensure that your solr schema (schema.xml) has the fields ‘id’, ‘name’, ‘desc’. Change the appropriate details in the data-config.xml

Step 4: Drop your JDBC driver jar file into the <solr-home>/lib directory .

Step 5 : Run the command http://solr-host:port/solr/dataimport?command=full-import. Keep in mind that every time a full-import is executed the index is cleaned up. If you do not wish that to happen add clean=false. For example: http://solr-host:port/solr/dataimport?command=full-import&clean=false

 

Index the fields in different names

Step: 1 Change the data-config as follows :

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/dbname" 
              user="user-name" 
              password="password"/>
  <document>
    <entity name="id" 
            query="select id,name,desc from mytable">
       <field column="id" name="solr_id"/>
       <field column="name" name="solr_name"/>
       <field column="desc" name="solr_desc"/>
    </entity>
  </document>
</dataConfig>

Step 2 : This time the fields will be written to the solr fields ‘solr_id’, ‘solr_name’, solr_desc’. You must have these fields in the schema.xml. Step 3 : Run the command http://solr-host:port/dataimpor?command=full-import

 

Index data from multiple tables into Solr

Step: 1 Change the data-config as follows :

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/dbname" 
              user="user-name" 
              password="password"/>
  <document>
    <entity name="outer" 
            query="select id,name,desc from mytable">
       <field column="id" name="solr_id"/>
       <field column="name" name="solr_name"/>
       <field column="desc" name="solr_desc"/>
       <entity name="inner"
               query="select details from another_table where id ='${outer.id}'">
              <field column="details" name="solr_details"/> 
       </entity>
    </entity>
  </document>
</dataConfig>

Step 2: The schema.xml should have the solr_details field

Step 3: Run the full-import command