You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by sabman <sa...@gmail.com> on 2011/07/21 21:26:10 UTC

Using Scriptransformer to send a HTTP Request

I am using solr to index RSS feeds and I am using DataImportHandler to parse
the urls and then index them. Now I have implemented a web service that
takes a url and creates an thumbnail image and stores it in a local
directory.

So here is what I want to do: After the url is parsed, I want to send a Http
request to the web service with the URL. ScriptTransformer seemed the way to
go and here is how my data-config.xml file looks.

<dataConfig>


  <dataSource type="JdbcDataSource" name="dbSource"
driver="com.mysql.jdbc.Driver" 
url="jdbc:mysql://localhost/solr_sources" user="root" password="******"/>



  <document>

    <entity name="rssFeedItems" rootEntity="false"  dataSource="dbSource" 
query="select url from rss_feeds">

      <entity name="rssFeeds" dataSource="urlSource"
url="${rssFeedItems.url}" transformer="script:sendURLRequest"
processor="XPathEntityProcessor" forEach="/rss/channel/item">
        <field column="title"        xpath="/rss/channel/item/title"/>
        <field column="link"         xpath="/rss/channel/item/link" />
        <field column="description"  xpath="/rss/channel/item/description"
/>
        <field column="date_published" xpath="/rss/channel/item/pubDate"/>
      </entity>
    </entity>
.................
................


As you can see from the data-config file, I am currently testing to see if
this would work by hard coding a dummy URL. 

url.openConnection().connect(); Should make the HTTP Request. But the image
is not generated.

I see no compile errors. I tried the example script of printing out a
message 

var v = new java.lang.Runnable() {
                    run: function() {
print('********************PRINTING************************'); }
               }
       v.run();

And it worked. 

I even played around with the function names to force it throw some compile
errors and it did throw errors which shows that it is able to create the
objects of class type URL and URL Connection.

Any suggestions?

--
View this message in context: http://lucene.472066.n3.nabble.com/Using-Scriptransformer-to-send-a-HTTP-Request-tp3189479p3189479.html
Sent from the Solr - User mailing list archive at Nabble.com.