Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

SMILA/5 Minutes Tutorial

< SMILA
Revision as of 11:42, 28 November 2008 by Dhazin.brox.de (Talk | contribs)

This page contains installation instructions for the SMILA application and helps you with your first steps in SMILA. Please note that in this tutorial as well as in the SMILA application you may sometimes come across the abbreviation EILF, which refers to the former name of the SMILA project.

1. Download and unpack the SMILA application.

Save-and-extract.png

If you use Linux version of SMILA please make sure that the file SMILA has executable permissions. If not, you can set it by running chmod +x ./SMILA command in the terminal.

2. Start the SMILA engine.

To start the SMILA engine open a terminal, navigate to the directory that contains the extracted files, and run the SMILA (EILF) executable. Wait until the engine is fully started. If everything is OK, you should see output similar to the one on the following screenshot:

Start-engine.png

Please note that to run SMILA you need to have jre executable added to your PATH environment variable. The jvm version should be at least java 5.

Optionally you can configure jvm into SMILA.ini file instead of environment variable. Put the argument -vm <path/to/jre/executable> at the beginning of SMILA.ini, for example:

-vm
/usr/java/jre1.5.0.16/bin/java
...

3. Check the log file.

You can check what's happening in the background by opening the SMILA log file in an editor. This file is named SMILA.log (EILF.log) and can be found in the same directory as the SMILA executable.

Log-file.png

4. Configure the crawling jobs.

Now when the SMILA engine is up and running we can start the crawling jobs. Crawling jobs are managed over the JMX protocol, that means that we can connect to SMILA with a JMX client of your choice. We will use JConsole for that purpose since this JMX client is already available as a default with the Sun Java distribution.

Start the JConsole executable in your JDK distribution. If the client is up and running, select the PID in the Connect window and click Connect.

Jconsole-connect.png

Next, switch to the MBeans tab, expand the SMILA (EILF) node in the MBeans tree on the left side of the window, and click the org.eclipse.smila.connectivity.framework.CrawlerController node. This node is used to manage and monitor all crawling activities. Click a sub node and find the crawling attributes on the right pane.

Mbeans-overview.png

5. Start the file system crawler.

To start a file system crawler, open the Operations tab on the right pane, type "file" into the text field next to the startCrawl button and click the button.

Start-file-crawl.png

You should receive a message similar to the following, indicating that the crawler has been successfully started:

Start-crawl-file-result.png

Now we can check the log file to see what happened:

File-crawl-log.png

6. Configuring the file system crawler.

Maybe you have already noticed the following error message in your log output after starting the file system crawler:

2008-09-11 18:14:36,059 [Thread-13] ERROR impl.CrawlThread - org.eclipse.smila.connectivity.framework.CrawlerCriticalException: Folder "c:\data" is not found

The error message above states that the crawler tried to index a folder at c:\data but was not able to find this it. To solve this, let's create a folder with sample data, say ~/tmp/data, put some dummy text files into it, and configure the file system crawler to index it. To configure the crawler to index the new directory instead of c:\data, open the configuration file of the crawler at configuration/org.eclipse.smila.connectivity.framework/file. Modify the BaseDir attribute by setting its value to an absolute path that points to your sample directory. Don't forget to save the file.

File-crawl-config-with-data.png

Now start the file system crawler with JConsole again (see step 5). This time there should be something interesting in the log file:

Filesystem-crawler-in-work.png

It looks like something was indexed. In the next step we'll try to search on the index that was created.

7. Searching on the indices.

To search on the indices that were created by the crawlers, point your browser to http://localhost:8080/AnyFinder/SearchForm. Find the name of all available indices in the left column below the Indexlist header. Currently, there should be only one index in the list. Click its name to open the search form:

Eilf-search-form.png

Now let's try to search for a word from which you know that it occurs in your dummy files. In this tutorial, we know that there was a word "data" in a file named sample.txt.

Searching-for-text-in-file.png

There was also a file named file 1.txt in the sample folder. Let's check whether it was indexed. Type "1.txt" in the Filename field and click the search icon again:

Searching-by-filename.png

8. Configure and run the web crawler.

Now that we know how to start and configure the file system crawler and how to search on indices configuring and running the web crawler is straightforward: The configuration file of the web crawler is located at configuration/org.eclipse.smila.connectivity.framework directory and is named web:

Webcrawler-config.png

By default the web crawler is configured to index the URL http://www.brox.de website. To change this, open the file in an editor of your choice and set the content of the <Seed> element to the desired web site. Detailed information on the configuration of the web crawler is also available at the Web crawler configuration page.

To start the crawling process, save the configuration file, open the Operations tab in JConsole again, type "web" into the text field next to the startCrawl button, and click the button.

Starting-web-crawler.png

Note that the Operations tab in JConsole also provides buttons to stop a crawler, get the list of active crawlers and the current status of a particular crawling job. As an example the following screenshot shows the result after the getActiveCrawlsStatus button has been clicked while the web crawler is running:

One-active-crawl-found.png

When the web crawler's job is finished, you can search on the generated index just like described above with the file system crawler (see step 7).

Webcrawler-index-search.png

5 Minutes for Changing Workflow

In previous sections all data collected by crawlers was processed with the same workflow and indexed into the same index, test_index. It's possible to configure SMILA so that data from different data sources will go through different workflows and will be indexed into different indices. This will require more advanced configuration than before but still is quite simple. Let's create additional workflow for webcrawler records so that webcrawler data will be indexed into separate index, say web_index.

1. Modify Listener rules.

First, lets modify the default add rule in the Listener and add another rule that will make webcrawler records to be processed by separate BPEL workflow. For more information about Listener, please see the section Listener of the QueueWorker documentation. Listener configuration is placed at the configuration/org.eclipse.smila.connectivity.queue.worker/ListenerConfig.xml Open that file and edit the <Condition> tag of the Default ADD Rule. The result should be as follows:

<Rule Name="Default ADD Rule" WaitMessageTimeout="10" Workers="2">
  <Source BrokerId="broker1" Queue="SMILA.connectivity"/>
  <Condition>Operation='ADD' and NOT(DataSourceID LIKE 'web%')</Condition>
  <Task>
    <Process Workflow="AddPipeline"/>
  </Task>
</Rule>

Now add the following new rule to this file:

<Rule Name="Web ADD Rule" WaitMessageTimeout="10" Workers="2">
  <Source BrokerId="broker1" Queue="SMILA.connectivity"/>
  <Condition>Operation='ADD' and DataSourceID LIKE 'web%'</Condition>
  <Task>
    <Process Workflow="AddWebPipeline"/>
  </Task>
</Rule>

Notice that we modified condition in the Default ADD Rule to skip webcrawler data. Webcrawler data will be processed by new Web ADD Rule. Web ADD Rule defines that webcrawler data will be processed by AddWebPipeline workflow, so next we need to create AddWebPipeline workflow.

2. Create workflow for the BPEL WorkflowProcessor

We need to add the AddWebPipeline workflow to BPEL WorkflowProcessor. For more information about BPEL WorkflowProcessor please check the BPEL WorkflowProcessor documentation. BPEL WorkflowProcessor configuration files are placed at the configuration/org.eclipse.smila.processing.bpel/pipelines directory. There is a file addpipeline.bpel that defines AddPipeline process. Let's create the addwebpipeline.bpel file that will define AddWebPipeline process and put the following code into it:

<?xml version="1.0" encoding="utf-8" ?>
<process name="AddWebPipeline" targetNamespace="http://www.eclipse.org/smila/processor"
    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:proc="http://www.eclipse.org/smila/processor" 
    xmlns:rec="http://www.eclipse.org/smila/record">
 
  <import location="processor.wsdl" namespace="http://www.eclipse.org/smila/processor"
      importType="http://schemas.xmlsoap.org/wsdl/" />
 
  <partnerLinks>
    <partnerLink name="Pipeline" partnerLinkType="proc:ProcessorPartnerLinkType" myRole="service" />
  </partnerLinks>
 
  <extensions>
    <extension namespace="http://www.eclipse.org/smila/processor" mustUnderstand="no" />
  </extensions>
 
  <variables>
    <variable name="request" messageType="proc:ProcessorMessage" />
  </variables>
 
  <sequence>
    <receive name="start" partnerLink="Pipeline" portType="proc:ProcessorPortType" operation="process"
        variable="request" createInstance="yes" />
 
    <!-- only process text based content, skip everything else -->
    <if name="conditionIsText">
      <condition>contains($request.records/rec:Record[1]/rec:A[@n="MimeType"]/rec:L/rec:V, "text/")</condition>
      <sequence name="processTextBasedContent">		  
 
        <!-- extract txt from html files -->
        <if name="conditionIsHtml">
          <condition>($request.records/rec:Record[1]/rec:A[@n="MimeType"]/rec:L/rec:V[contains(., "text/html")]) or ($request.records/rec:Record[1]/rec:A[@n="MimeType"]/rec:L/rec:V[contains(., "text/xml")])</condition>
        </if>				
 
        <extensionActivity name="invokeHtml2Txt">
          <proc:invokePipelet>
            <proc:pipelet class="org.eclipse.smila.processing.pipelets.HtmlToTextPipelet" />
            <proc:variables input="request" output="request" />
            <proc:PipeletConfiguration>
              <proc:Property name="inputType">
                <proc:Value>ATTACHMENT</proc:Value>
              </proc:Property>				       
              <proc:Property name="outputType">
                <proc:Value>ATTACHMENT</proc:Value>
              </proc:Property>
              <proc:Property name="inputName">
                <proc:Value>Content</proc:Value>
              </proc:Property>
              <proc:Property name="outputName">
                <proc:Value>Content</proc:Value>
              </proc:Property>
              <proc:Property name="meta:title">
                <proc:Value>Title</proc:Value>
              </proc:Property>					
            </proc:PipeletConfiguration>       								
          </proc:invokePipelet>
        </extensionActivity>
 
        <extensionActivity name="invokeLuceneService">
          <proc:invokeService>
            <proc:service name="LuceneIndexService" />
            <proc:variables input="request" output="request" />
            <proc:setAnnotations>
              <rec:An n="org.eclipse.smila.lucene.LuceneIndexService">
                <rec:V n="indexName">web_index</rec:V>
                <rec:V n="executionMode">ADD</rec:V>
              </rec:An>
            </proc:setAnnotations>
          </proc:invokeService>
        </extensionActivity>
 
      </sequence>				
    </if>		
 
    <reply name="end" partnerLink="Pipeline" portType="proc:ProcessorPortType" operation="process" variable="request" />
    <exit />
  </sequence>
</process>

Note that we use "web_index" index name for the LuceneService in the code above:

<rec:An n="org.eclipse.smila.lucene.LuceneIndexService">
  <rec:V n="indexName">web_index</rec:V>
  <rec:V n="executionMode">ADD</rec:V>
</rec:An>

We need to add our pipeline description to the deploy.xml file placed in the same directory. Add the following code to the end of deploy.xml before the </deploy> tag:

<process name="proc:AddWebPipeline">
  <in-memory>true</in-memory>
  <provide partnerLink="Pipeline">
    <service name="proc:AddWebPipeline" port="ProcessorPort" />
  </provide>    
</process>

Now we need to add our web_index to LuceneIndexService configuration.

3. LuceneIndexService configuration

For more information about LuceneIndexService, please see LuceneIndexService

Let's configure our web_index index structure and search template. Add the following code to the end of configuration/org.eclipse.smila.search.datadictionary/DataDictionary.xml file before the </AnyFinderDataDictionary> tag:

<Index Name="web_index">
  <Connection xmlns="http://www.anyfinder.de/DataDictionary/Connection" MaxConnections="5"/>
  <IndexStructure xmlns="http://www.anyfinder.de/IndexStructure" Name="web_index">
    <Analyzer ClassName="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
    <IndexField FieldNo="8" IndexValue="true" Name="MimeType" StoreText="true" Tokenize="true" Type="Text"/>
    <IndexField FieldNo="7" IndexValue="true" Name="Size" StoreText="true" Tokenize="true" Type="Text"/>
    <IndexField FieldNo="6" IndexValue="true" Name="Extension" StoreText="true" Tokenize="true" Type="Text"/>
    <IndexField FieldNo="5" IndexValue="true" Name="Title" StoreText="true" Tokenize="true" Type="Text"/>
    <IndexField FieldNo="4" IndexValue="true" Name="Url" StoreText="true" Tokenize="false" Type="Text">
      <Analyzer ClassName="org.apache.lucene.analysis.WhitespaceAnalyzer"/>
    </IndexField>
    <IndexField FieldNo="3" IndexValue="true" Name="LastModifiedDate" StoreText="true" Tokenize="false" Type="Text"/>
    <IndexField FieldNo="2" IndexValue="true" Name="Path" StoreText="true" Tokenize="true" Type="Text"/>
    <IndexField FieldNo="1" IndexValue="true" Name="Filename" StoreText="true" Tokenize="true" Type="Text"/>
    <IndexField FieldNo="0" IndexValue="true" Name="Content" StoreText="true" Tokenize="true" Type="Text"/>
  </IndexStructure>
  <Result>
    <Field FieldNo="0" Name="ID"/>
  </Result>
  <Configuration xmlns="http://www.anyfinder.de/DataDictionary/Configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.anyfinder.de/DataDictionary/Configuration ../xml/DataDictionaryConfiguration.xsd">
    <DefaultConfig>
      <Field FieldNo="8">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="7">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="6">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>        
      <Field FieldNo="5">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="4">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="3">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="2">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="1">
        <FieldConfig Constraint="optional" Weight="1" xsi:type="FTText">
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="OR" Tolerance="exact"/>
        </FieldConfig>
      </Field>
      <Field FieldNo="0">
        <FieldConfig Constraint="required" Weight="1" xsi:type="FTText">
          <NodeTransformer xmlns="http://www.anyfinder.de/Search/ParameterObjects" Name="urn:ExtendedNodeTransformer">
            <ParameterSet xmlns="http://www.brox.de/ParameterSet"/>
          </NodeTransformer>
          <Parameter xmlns="http://www.anyfinder.de/Search/TextField" Operator="AND" Tolerance="exact"/>
        </FieldConfig>
      </Field>
    </DefaultConfig>
    <Result Name="">
      <ResultField FieldNo="8" Name="MimeType"/>
      <ResultField FieldNo="7" Name="Size"/>
      <ResultField FieldNo="6" Name="Extension"/>
      <ResultField FieldNo="5" Name="Title"/>
      <ResultField FieldNo="4" Name="Url"/>
      <ResultField FieldNo="3" Name="LastModifiedDate"/>
      <ResultField FieldNo="2" Name="Path"/>
      <ResultField FieldNo="1" Name="Filename"/>
    </Result>
    <HighlightingResult Name="">
      <HighlightingResultField FieldNo="0" Name="Content" xsi:type="HLTextField">
        <HighlightingTransformer Name="urn:Sentence">
          <ParameterSet xmlns="http://www.brox.de/ParameterSet">
            <Parameter Name="MaxLength" xsi:type="Integer">
              <Value>300</Value>
            </Parameter>
            <Parameter Name="MaxHLElements" xsi:type="Integer">
              <Value>999</Value>
            </Parameter>
            <Parameter Name="MaxSucceedingCharacters" xsi:type="Integer">
              <Value>30</Value>
            </Parameter>
            <Parameter Name="SucceedingCharacters" xsi:type="String">
              <Value>...</Value>
            </Parameter>
            <Parameter Name="SortAlgorithm" xsi:type="String">
              <Value>Occurrence</Value>
            </Parameter>
            <Parameter Name="TextHandling" xsi:type="String">
              <Value>ReturnSnipplet</Value>
            </Parameter>
          </ParameterSet>
        </HighlightingTransformer>
        <HighlightingParameter xmlns="http://www.anyfinder.de/DataDictionary/Configuration/TextHighlighting"/>
      </HighlightingResultField>
    </HighlightingResult>
  </Configuration>
</Index>

Now we need to add mapping of attribute and attachment names to Lucene "FieldNo" defined in DataDictionary.xml. Open configuration/org.eclipse.smila.lucene/Mappings.xml file and add the following code to the end of file before </Mappings> tag:

<Mapping indexName="web_index">
  <Attributes>
    <Attribute name="Filename" fieldNo="1" />
    <Attribute name="Path" fieldNo="2" />    
  <Attribute name="LastModifiedDate" fieldNo="3" />
  <Attribute name="Url" fieldNo="4" />
  <Attribute name="Title" fieldNo="5" />    
  <Attribute name="Extension" fieldNo="6" />
  <Attribute name="Size" fieldNo="7" />
  <Attribute name="MimeType" fieldNo="8" />           
  </Attributes>
  <Attachments>
    <Attachment name="Text" fieldNo="0" />      
  </Attachments>
</Mapping>

4. Put it all together

Ok, now it seems that we finally finished configuring SMILA for using separate workflows for Filesystem and Web crawlers and index data from these crawlers into different indices. Here is what we have done so far:

  1. Modified Listener rules to use different workflows for Filesystem and Web crawlers
  2. Created new BPEL workflow for Web crawler
  3. Added webcrawler index to the lucence configurations.

No we can start SMILA again and look what's happening when we start Web crawler:

Web index.png


It seems that Web crawler data is now indexed to the web_index as expected. Now we can also search on the web_index from browser:

Web index-search.png

Configuration overview

SMILA configuration files are placed into configuration directory of the SMILA application. Following figure shows configuration files relevant to this tutorial, regarding SMILA components and data lifecycle. SMILA components names are black-colored, directories containing configuration files and filenames are blue-colored.

Smila-configuration-overview.jpg

Back to the top