Launching Aspire in Console Mode

From wiki.searchtechnologies.com
Jump to: navigation, search

For Information on Aspire 3.1 Click Here

 (1.3 Release)  

Aspire Shell

Aspire Shell is a Command Line Interface for configuring, testing, and executing any document processing tasks in Aspire.

Starting Up Aspire in Console Mode

To start Aspire, execute the "aspiresh.sh" script in the "bin" directory.

Linux

Set your working directory to your Aspire distribution and then execute "bin/aspiresh.sh" (make sure it has execute permission for your user):

$ cd my-aspire/target/my-aspire-1.0-SNAPSHOT-distribution.dir
$ bin/aspiresh.sh



************************************************************************
*
* ASPIRE BOOTLOADER
*
* Bundle id : 10
*
* Location  : file:bundles/boot/aspire-bootloader-1.3-SNAPSHOT.jar
*

Maven update policy: always


Settings (org.apache.felix.webconsole.internal.servlet.OsgiManager):  {password=admin, manager.root=/osgi, username=admin}
Maven update policy: always
Aspire Console Mode
Aspire>

Microsoft Windows from the Command Prompt

Set your working directory to your Aspire distribution and then execute "bin\aspiresh.bat":

$ cd my-aspire\target\my-aspire-1.0-SNAPSHOT-distribution.dir
$ bin\aspiresh.bat
Removing Felix-Cache and AppBundle-Cache directories



************************************************************************
*
* ASPIRE BOOTLOADER
*
* Bundle id : 10
*
* Location  : file:bundles/boot/aspire-bootloader-1.3-SNAPSHOT.jar
*

Maven update policy: always


Settings (org.apache.felix.webconsole.internal.servlet.OsgiManager):  {password=admin, manager.root=/osgi, username=admin}
Maven update policy: always
Aspire Console Mode
Aspire>

Using Aspire Shell

Groovy in Aspire Shell

One of the most powerful features in Aspire Shell is the ability to parse and evaluate Groovy Expressions on the fly, just as GroovyShell does. But not only normal Groovy Expressions but also Aspire Groovy Pipelines expressions.


Aspire> 5 + 6
11
Aspire> pritnln "hello world, this is Aspire Shell"
hello world, this is Aspire Shell

Loading components

You can load any component by just typing its configuration:

Example:

Aspire> <component name="FetchUrl" subType="default" factoryName="aspire-fetch-url" />
Aspire> <component name="ExtractText" subType="default" factoryName="aspire-extract-text" />
Aspire> 

You can also load components with multiple line configurations:

Aspire> <component name="PostHTTP" subType="default" factoryName="aspire-post-http">
Aspire:   <postUrl>http://localhost:8983/solr/update</postUrl>
Aspire:   <postXsl>config/xsl/aspireToSolr.xsl</postXsl>
Aspire:   <okayResponse><![CDATA[<int name="status">0</int>]]></okayResponse>
Aspire: </component>
Aspire>

Each component loaded can be accessed by its name:

Aspire> FetchUrl
<component name="FetchUrl" subType="default" factoryName="aspire-fetch-url"/>

Aspire> ExtractText
<component name="ExtractText" subType="default" factoryName="aspire-extract-text"/>

Aspire> PostHTTP
<component name="PostHTTP" subType="default" factoryName="aspire-post-http">
  <postUrl>http://localhost:8983/solr/update</postUrl>
  <postXsl>config/xsl/aspireToSolr.xsl</postXsl>
  <okayResponse><int name="status">0</int></okayResponse>
</component>

Aspire>

Creating jobs in Aspire Shell

From Aspire Shell you can create your own jobs in order to process them through your own Groovy Pipelines.

Example:

Aspire>  myJob = <doc>
Aspire:    <fetchUrl>http://www.searchtechnologies.com</fetchUrl>
Aspire:  </doc>
** localhost:50505/2013-06-04T15:42:28Z/0 **
<doc>
  <fetchUrl>http://www.searchtechnologies.com</fetchUrl>
</doc>

Aspire>

Using Groovy Pipelines

If you have already loaded some components and created a job to process, you can use groovy pipelines to process it. (For more details on groovy pipelines click here)

Example:

Aspire> myJob | FetchUrl | ExtractText
** localhost:50505/2013-06-04T19:03:29Z/0 **
<doc>
  <content>
    ...
    //CONTENT EXTRACTED
    ...
  </content>
  <extension source="FetchURLStage">
    <field name="status">HTTP/1.1 200 OK</field>
    <field name="Cache-Control">private</field>
    <field name="Content-Length">24233</field>
    <field name="Content-Type">text/html; charset=utf-8</field>
    <field name="Server">Microsoft-IIS/7.5</field>
    <field name="X-AspNet-Version">2.0.50727</field>
    <field name="Set-Cookie">ASP.NET_SessionId=rs31fw3r23u3j42unooa5tj1; path=/; HttpOnly</field>
    <field name="X-Powered-By">ASP.NET</field>
    <field name="Date">Tue, 04 Jun 2013 19:21:19 GMT</field>
  </extension>
  <extension source="ExtractTextStage">
    <field name="Content-Location">http://www.searchtechnologies.com</field>
    <field name="Content-Encoding">ISO-8859-1</field>
    <field name="resourceName">http://www.searchtechnologies.com</field>
    <field name="google-site-verification">jP1bIfjuuyZUYfTkYc_O6ZlTHxCm07voTDcMk72Z8oQ</field>
  </extension>
  <title source="ExtractTextStage/title">The Enterprise Search Implementation Experts</title>
  <protocol source="FetchURLStage/protocol">http</protocol>
  <keywords source="ExtractTextStage/keywords">Enterprise Search, Search Engine Experts, Consulting</keywords>
  <host source="FetchURLStage/host">www.searchtechnologies.com</host>
  <fetchUrl>http://www.searchtechnologies.com</fetchUrl>
  <description source="ExtractTextStage/description">Search Technologies is the largest IT services company dedicated to enterprise search implementation, consulting, and managed services. Our expertise covers all leading search products, and all aspects of search applications.</description>
  <encoding source="FetchURLStage/encoding">utf-8</encoding>
  <contentType source="ExtractTextStage/Content-Type">application/xhtml+xml</contentType>
  <httpResponse code="200" source="FetchURLStage">OK</httpResponse>
  <mimeType source="FetchURLStage/mimeType">text/html</mimeType>
</doc>

Aspire>

Aspire Shell commands

Besides groovy expressions you can also use some special commands in Aspire Shell. Those commands are listed in the following table:

Command Parameters Description
components none Shows the components loaded inside the current aspire shell application
createJob XML string of an AspireObject Creates a job based on the XML string of an AspireObject.
reload none Reloads all the components already loaded in the current aspire shell application, and cleans every non saved groovy expression.
reset none Removes the current aspire shell application and load it again. Also and cleans every non saved groovy expression.
load <application-xml-file> Loads the specified application into aspire. Any previous aspire shell application will be unloaded. Cleans up every non saved groovy expression.
save <application-xml-file> Saves the current aspire shell application as XML into the specified file. Every groovy expression will be saved as a groovy pipeline, ready to be executed.
run <application-xml-file> Run the groovy expressions saved in the specified application file. Every loaded components and groovy expressions will be replaced by those in the specified application file.
cd <directory> Change the working directory for the 'dir' groovy pipeline function. (For more details click [[Aspire_2.0_Pipeline_Manager#Filesystem_job_feeder here])
pwd none Shows the working directory for the 'dir' groovy function. (For more details click [[Aspire_2.0_Pipeline_Manager#Filesystem_job_feeder here])
help none or <command-name> Shows the help for aspire shell. If no arguments then it shows all the available commands, if specified a command-name as argument, it shows the description for that command.
clear none Clears the command buffer and discard it. Any multiple line command input will be escaped. It can be invoked by the shortcut CTRL-D
cls none Clears the console output
felix none Enter felix mode to execute felix commands. (No AspireShell commands will be available here)
exit none If performed in felix mode, it returns to Aspire Shell mode, else exit AspireShell and then shutdown felix.
shutdown none Exit AspireShell and shutdown felix.

Command usage

components
Aspire> components
FetchUrl        com.searchtechnologies:aspire-fetch-url:2.2.2 / default
ExtractText     com.searchtechnologies:aspire-extract-text:2.2.2 / default
PostHTTP        com.searchtechnologies:aspire-post-http:2.2.2 / default
Aspire>
createJob
Aspire>myJob = createJob('<doc><url>http://www.searchtechnologies.com</url></doc>')
** 10.10.21.34:50505/2014-06-23T20:53:32Z/0 **
<doc>
  <url>http://www.searchtechnologies.com</url>
</doc>
Aspire>

You can also skip the createJob command and create a job directly (which will call the createJob method in the background):

Aspire>myJob = <doc><url>http://www.searchtechnologies.com</url></doc>
** 10.10.21.34:50505/2014-06-23T20:53:32Z/0 **
<doc>
  <url>http://www.searchtechnologies.com</url>
</doc>
Aspire>
reload
Aspire>reload
Aspire>
reset
Aspire> reset
Aspire>
save
Aspire> println "hello world, this is AspireShell"
hello world, this is AspireShell
Aspire> save config/savedApp.xml
Aspire>
load
Aspire> load config/savedApp.xml
Aspire>
run
Aspire> run config/savedApp.xml
hello world, this is AspireShell
Aspire>
cd & pwd
Aspire> cd config
Aspire> pwd
C:\\distributions\my-aspire\target\my-aspire-2.2.2-distribution.dir\config
Aspire> cd ..
Aspire> pwd 
C:\\distributions\my-aspire\target\my-aspire-2.2.2-distribution.dir
clear
Aspire> <component name="PostHTTP" subType="default" factoryName="aspire-post-http">
Aspire: clear
Aspire>

You can also use the clear shortcut CTRL-D

Aspire> <component name="PostHTTP" subType="default" factoryName="aspire-post-http">
Aspire: <CTRL-D>
Aspire>
cls
Aspire> cls
 
 
Aspire>
felix
Aspire> felix
Felix> find aspire
START LEVEL 1
   ID   State         Level  Name
[  11] [Active     ] [    1] Aspire Application (2.2.2)
Felix> exit
Aspire>
shutdown
Aspire> shutdown
Aspire> Stopping bundle: 11 - file:/C:/Users/aaguilar/.m2/repository/com/searchtechnologies/aspire-application/2.2.2/aspire-application-2.2.2.jar
Stopped component factory: aspire-application (bundle 11)
AspireShell: Shutting down...
$

Running Applications

You can use Aspire Shell to run at startup applications you have previously saved in your filesystem:

$ bin\aspiresh.bat config/savedApp.xml
Removing Felix-Cache and AppBundle-Cache directories



************************************************************************
*
* ASPIRE BOOTLOADER
*
* Bundle id : 10
*
* Location  : file:bundles/boot/aspire-bootloader-1.3-SNAPSHOT.jar
* 

Maven update policy: always


Settings (org.apache.felix.webconsole.internal.servlet.OsgiManager):  {password=admin, manager.root=/osgi, username=admin}
Maven update policy: always
Aspire Console Mode
hello world, this is AspireShell
Aspire> Stopping bundle: 11 - file:/C:/Users/aaguilar/.m2/repository/com/searchtechnologies/aspire-application/1.3-SNAPSHOT/aspire-application-1.3-SNAPSHOT.jar
Stopped component factory: aspire-application (bundle 11)
AspireShell: Shutting down...

$

You can add the --no-exit option to avoid AspireShell from shutting down after running the application.

$ bin\aspiresh.bat config/savedApp.xml --no-exit
Removing Felix-Cache and AppBundle-Cache directories



************************************************************************
*
* ASPIRE BOOTLOADER
*
* Bundle id : 10
*
* Location  : file:bundles/boot/aspire-bootloader-1.3-SNAPSHOT.jar
* 

Maven update policy: always


Settings (org.apache.felix.webconsole.internal.servlet.OsgiManager):  {password=admin, manager.root=/osgi, username=admin}
Maven update policy: always
Aspire Console Mode
hello world, this is AspireShell
Aspire>