You are viewing a plain text version of this content. The canonical link for it is here.
Posted to droids-dev@incubator.apache.org by Bertil Chapuis <co...@bertil.ch> on 2009/09/09 08:38:35 UTC

Customizable Solr Handle

Hello,

My name is Bertil Chapuis. I am using droids for a personal project and
I am trying to create a more customizable solr handler. 

I posted a ticket with my code (DROIDS-62). However, I am looking for a
way to filter the handler's execution. I'd like to handle the documents
only if their URI or content matches specific conditions.

For example, the document is handled only if its uri matches the
following regex:

http://www.awebsite.com/document-[0-9]*.htm

What's the best way to do that? Is it delegated to the handler's
implementation or is there a standard way?

Best regards,

Bertil Chapuis



Re: Customizable Solr Handle

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Thu, 2009-09-24 at 16:32 +0200, Bertil Chapuis wrote:
> Of course, I agree, this should be improved. I did that because I wanted
> something which use a sax approach instead of xpath. I think it make
> sense since xpath requires to build a DOM from the page.
> 

Nupp, that is not true though. 

> In my case, i finally used an other solution which is a bit different.
> In the handler, I use an embedded pipeline (cocoon 3) to apply a
> sequence of XSLT transformations on the parse. The goal is to obtain an
> XML document in the form:
> 
>  <doc>
>   <field name="fieldname">value</field>
>   ...	
>  </doc>

jeje, lol you are using cocoon. nice. That is something I can very much
relate to (I am using it since 2001). ;)

> 
> eventually, a custom cocoon consumer sends the values to solr and commit
> the result.
> 
> I didn't sent the code because the approach was a bit strange. However
> in my case i works well and i can use it to handle nearly everything.

No please I would love to see this code since I actually do the same in
my usecase connecting to solr. You may know
http://wiki.apache.org/solr/SolrForrest which in the end works with
cocoon 2.1 and 2.2.

> 
> What do you think about such a solution? I have a little time next week
> so I should be able to provide something more decent.

This would be an awesome contribution. I would love to see it.

salu2

> 
> Best regards,
> 
> Bertil
> 
> 
> 
> 
> On Thu, 2009-09-24 at 11:19 +0200, Thorsten Scherler wrote:
> > On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > > Hello,
> > > 
> > > My name is Bertil Chapuis. I am using droids for a personal project and
> > > I am trying to create a more customizable solr handler. 
> > > 
> > > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > > way to filter the handler's execution. I'd like to handle the documents
> > > only if their URI or content matches specific conditions.
> > > 
> > > For example, the document is handled only if its uri matches the
> > > following regex:
> > > 
> > > http://www.awebsite.com/document-[0-9]*.htm
> > > 
> > > What's the best way to do that? 
> > 
> > I had a chance to test this patch but in the end I could not use it for
> > my use case. The problem that I have with it it that is limiting the
> > access to the different elements in the tree to much. It is not generic
> > since instead of using xpath expression (the standard approach to solve
> > such a usecase) it uses "standard regexp". 
> > 
> > Further having a strong background on xml myself it stroke me ought to
> > have element[0] which in xpath would have been element[1].
> > 
> > IMO if you can add xpath support to this component then it really rocks
> > for many usecases since we would have a generic parser solution to
> > extract informations the way it is now it will be for very few use
> > cases.
> > 
> > salu2
> > 
> > > Is it delegated to the handler's
> > > implementation or is there a standard way?
> > > 
> > > Best regards,
> > > 
> > > Bertil Chapuis
> > > 
> > > 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





Re: Customizable Solr Handle

Posted by Bertil Chapuis <co...@bertil.ch>.
Of course, I agree, this should be improved. I did that because I wanted
something which use a sax approach instead of xpath. I think it make
sense since xpath requires to build a DOM from the page.

In my case, i finally used an other solution which is a bit different.
In the handler, I use an embedded pipeline (cocoon 3) to apply a
sequence of XSLT transformations on the parse. The goal is to obtain an
XML document in the form:

 <doc>
  <field name="fieldname">value</field>
  ...	
 </doc>

eventually, a custom cocoon consumer sends the values to solr and commit
the result.

I didn't sent the code because the approach was a bit strange. However
in my case i works well and i can use it to handle nearly everything.

What do you think about such a solution? I have a little time next week
so I should be able to provide something more decent.

Best regards,

Bertil




On Thu, 2009-09-24 at 11:19 +0200, Thorsten Scherler wrote:
> On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > Hello,
> > 
> > My name is Bertil Chapuis. I am using droids for a personal project and
> > I am trying to create a more customizable solr handler. 
> > 
> > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > way to filter the handler's execution. I'd like to handle the documents
> > only if their URI or content matches specific conditions.
> > 
> > For example, the document is handled only if its uri matches the
> > following regex:
> > 
> > http://www.awebsite.com/document-[0-9]*.htm
> > 
> > What's the best way to do that? 
> 
> I had a chance to test this patch but in the end I could not use it for
> my use case. The problem that I have with it it that is limiting the
> access to the different elements in the tree to much. It is not generic
> since instead of using xpath expression (the standard approach to solve
> such a usecase) it uses "standard regexp". 
> 
> Further having a strong background on xml myself it stroke me ought to
> have element[0] which in xpath would have been element[1].
> 
> IMO if you can add xpath support to this component then it really rocks
> for many usecases since we would have a generic parser solution to
> extract informations the way it is now it will be for very few use
> cases.
> 
> salu2
> 
> > Is it delegated to the handler's
> > implementation or is there a standard way?
> > 
> > Best regards,
> > 
> > Bertil Chapuis
> > 
> > 


Re: Customizable Solr Handle

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Thu, 2009-09-24 at 18:25 +0200, Bertil Chapuis wrote:
> Did someone already try the jaxen package called saxpath? It may be a
> good solution to handle the content especially if the webpages or
> documents are very long.
> 

Yes, with this solution it should work fine.

salu2

> Best regards,
> 
> Bertil
> 
> On Thu, 2009-09-24 at 11:19 +0200, Thorsten Scherler wrote:
> > On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > > Hello,
> > > 
> > > My name is Bertil Chapuis. I am using droids for a personal project and
> > > I am trying to create a more customizable solr handler. 
> > > 
> > > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > > way to filter the handler's execution. I'd like to handle the documents
> > > only if their URI or content matches specific conditions.
> > > 
> > > For example, the document is handled only if its uri matches the
> > > following regex:
> > > 
> > > http://www.awebsite.com/document-[0-9]*.htm
> > > 
> > > What's the best way to do that? 
> > 
> > I had a chance to test this patch but in the end I could not use it for
> > my use case. The problem that I have with it it that is limiting the
> > access to the different elements in the tree to much. It is not generic
> > since instead of using xpath expression (the standard approach to solve
> > such a usecase) it uses "standard regexp". 
> > 
> > Further having a strong background on xml myself it stroke me ought to
> > have element[0] which in xpath would have been element[1].
> > 
> > IMO if you can add xpath support to this component then it really rocks
> > for many usecases since we would have a generic parser solution to
> > extract informations the way it is now it will be for very few use
> > cases.
> > 
> > salu2
> > 
> > > Is it delegated to the handler's
> > > implementation or is there a standard way?
> > > 
> > > Best regards,
> > > 
> > > Bertil Chapuis
> > > 
> > > 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





Re: Customizable Solr Handle

Posted by Bertil Chapuis <co...@bertil.ch>.
Did someone already try the jaxen package called saxpath? It may be a
good solution to handle the content especially if the webpages or
documents are very long.

Best regards,

Bertil

On Thu, 2009-09-24 at 11:19 +0200, Thorsten Scherler wrote:
> On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > Hello,
> > 
> > My name is Bertil Chapuis. I am using droids for a personal project and
> > I am trying to create a more customizable solr handler. 
> > 
> > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > way to filter the handler's execution. I'd like to handle the documents
> > only if their URI or content matches specific conditions.
> > 
> > For example, the document is handled only if its uri matches the
> > following regex:
> > 
> > http://www.awebsite.com/document-[0-9]*.htm
> > 
> > What's the best way to do that? 
> 
> I had a chance to test this patch but in the end I could not use it for
> my use case. The problem that I have with it it that is limiting the
> access to the different elements in the tree to much. It is not generic
> since instead of using xpath expression (the standard approach to solve
> such a usecase) it uses "standard regexp". 
> 
> Further having a strong background on xml myself it stroke me ought to
> have element[0] which in xpath would have been element[1].
> 
> IMO if you can add xpath support to this component then it really rocks
> for many usecases since we would have a generic parser solution to
> extract informations the way it is now it will be for very few use
> cases.
> 
> salu2
> 
> > Is it delegated to the handler's
> > implementation or is there a standard way?
> > 
> > Best regards,
> > 
> > Bertil Chapuis
> > 
> > 


Re: Customizable Solr Handle

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> Hello,
> 
> My name is Bertil Chapuis. I am using droids for a personal project and
> I am trying to create a more customizable solr handler. 
> 
> I posted a ticket with my code (DROIDS-62). However, I am looking for a
> way to filter the handler's execution. I'd like to handle the documents
> only if their URI or content matches specific conditions.
> 
> For example, the document is handled only if its uri matches the
> following regex:
> 
> http://www.awebsite.com/document-[0-9]*.htm
> 
> What's the best way to do that? 

I had a chance to test this patch but in the end I could not use it for
my use case. The problem that I have with it it that is limiting the
access to the different elements in the tree to much. It is not generic
since instead of using xpath expression (the standard approach to solve
such a usecase) it uses "standard regexp". 

Further having a strong background on xml myself it stroke me ought to
have element[0] which in xpath would have been element[1].

IMO if you can add xpath support to this component then it really rocks
for many usecases since we would have a generic parser solution to
extract informations the way it is now it will be for very few use
cases.

salu2

> Is it delegated to the handler's
> implementation or is there a standard way?
> 
> Best regards,
> 
> Bertil Chapuis
> 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





RE: Customizable Solr Handle

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Fri, 2009-09-11 at 11:16 +0100, Tony Dietrich wrote:
> See my previous post.
> 
> Websphinx is a good reference package for this structure.  Whoever wrote it
> was quite sensible.

https://issues.apache.org/jira/browse/DROIDS-58

Maybe you want to comment on this issue with the findings of websphinx.

salu2

> 
> Tony
> 
> -----Original Message-----
> From: Bertil Chapuis [mailto:contact@bertil.ch] 
> Sent: 11 September 2009 11:12
> To: droids-dev@incubator.apache.org
> Subject: RE: Customizable Solr Handle
> 
> I just had a look on the Droids architecture and I ask me if the Parser
> could not be considered as a Handler because in most handlers we will
> have to parse the content again. 
> 
> Doing this could lead to a simple generic filter mechanism. When
> executed, the Worker receive an object (Link, FileTask, etc) and for
> each Handlers test with the Filter(s) if the Handler should be executed
> or not.
> 
> filter.shouldExecute(Link, Handler){...}
> 
> What do you think about that? It could be a nice way to keep things
> simple and modular.
> 
> Best regards,
> 
> Bertil
> 
> 
> 
> On Wed, 2009-09-09 at 11:15 +0100, Tony Dietrich wrote:
> > Haven't got time atm to look at this myself, but there's a nice approach
> to this sort problem (of what to do with pages that (need to be)|(have been
> crawled) ) in the old websphinx package.
> > 
> > If I remember rightly, the package uses predicate classes (which can be
> standardised or sub-classed) and which return true/false in certain
> conditions, and methods in the crawler class which determine what actions
> are taken under which circumstances.
> > Ie 
> > public boolean shouldVisit(..){..}
> > public boolean shouldDownload(..){..}
> > public boolean shouldProcess(..){..}
> > with each method calling a declared predicate class (or chain of classes,
> depending on whether the implementation contains sub classed predicates.)
> > 
> > Perhaps a similar approach could be used for droids, since it very nicely
> provides a standards-acceptable, extensible approach to this sort of
> problem.
> > 
> > Perhaps overkill for Bertil's problem, but for future implementations
> .....
> > 
> > Tony
> > 
> > 
> > -----Original Message-----
> > From: Thorsten Scherler [mailto:thorsten.scherler.ext@juntadeandalucia.es]
> 
> > Sent: 09 September 2009 11:11
> > To: droids-dev@incubator.apache.org
> > Subject: Re: Customizable Solr Handle
> > 
> > On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > > Hello,
> > > 
> > > My name is Bertil Chapuis. I am using droids for a personal project and
> > > I am trying to create a more customizable solr handler. 
> > 
> > Hi Bertil, nice to have you on this list.
> > 
> > > 
> > > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > > way to filter the handler's execution. I'd like to handle the documents
> > > only if their URI or content matches specific conditions.
> > 
> > I will have a look at your patch, thanks in advance for your
> > contribution. 
> > 
> > > 
> > > For example, the document is handled only if its uri matches the
> > > following regex:
> > > 
> > > http://www.awebsite.com/document-[0-9]*.htm
> > > 
> > > What's the best way to do that? Is it delegated to the handler's
> > > implementation or is there a standard way?
> > 
> > Mingfai has this filter approach theoretically included in our next
> > version. However right now we do not have a standard approach other then
> > implementing the validation logic in e.g. the queue. The question is
> > whether you want only to crawl the pages that are valid against your
> > regex or the limitation is only for the handler. 
> > 
> > If it is only for the handler then it is maybe best to implement it in
> > your worker. Something like:
> > ...
> > public void execute(Link link) throws DroidsException, IOException {
> > 
> > ...
> > URI uri = link.getURI();
> > Pattern pattern = Pattern.compile(PATTERN);
> > Matcher matcher = pattern.matcher(uri);
> > if (matcher.find()) {
> >   droid.getHandlerFactory().handle(link.getURI(), entity);
> > }
> > ...}
> > 
> > 
> > HTH
> > 
> > salu2
> > 
> > > 
> > > Best regards,
> > > 
> > > Bertil Chapuis
> > > 
> > > 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





RE: Customizable Solr Handle

Posted by Tony Dietrich <to...@dietrich.org.uk>.
See my previous post.

Websphinx is a good reference package for this structure.  Whoever wrote it
was quite sensible.

Tony

-----Original Message-----
From: Bertil Chapuis [mailto:contact@bertil.ch] 
Sent: 11 September 2009 11:12
To: droids-dev@incubator.apache.org
Subject: RE: Customizable Solr Handle

I just had a look on the Droids architecture and I ask me if the Parser
could not be considered as a Handler because in most handlers we will
have to parse the content again. 

Doing this could lead to a simple generic filter mechanism. When
executed, the Worker receive an object (Link, FileTask, etc) and for
each Handlers test with the Filter(s) if the Handler should be executed
or not.

filter.shouldExecute(Link, Handler){...}

What do you think about that? It could be a nice way to keep things
simple and modular.

Best regards,

Bertil



On Wed, 2009-09-09 at 11:15 +0100, Tony Dietrich wrote:
> Haven't got time atm to look at this myself, but there's a nice approach
to this sort problem (of what to do with pages that (need to be)|(have been
crawled) ) in the old websphinx package.
> 
> If I remember rightly, the package uses predicate classes (which can be
standardised or sub-classed) and which return true/false in certain
conditions, and methods in the crawler class which determine what actions
are taken under which circumstances.
> Ie 
> public boolean shouldVisit(..){..}
> public boolean shouldDownload(..){..}
> public boolean shouldProcess(..){..}
> with each method calling a declared predicate class (or chain of classes,
depending on whether the implementation contains sub classed predicates.)
> 
> Perhaps a similar approach could be used for droids, since it very nicely
provides a standards-acceptable, extensible approach to this sort of
problem.
> 
> Perhaps overkill for Bertil's problem, but for future implementations
.....
> 
> Tony
> 
> 
> -----Original Message-----
> From: Thorsten Scherler [mailto:thorsten.scherler.ext@juntadeandalucia.es]

> Sent: 09 September 2009 11:11
> To: droids-dev@incubator.apache.org
> Subject: Re: Customizable Solr Handle
> 
> On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > Hello,
> > 
> > My name is Bertil Chapuis. I am using droids for a personal project and
> > I am trying to create a more customizable solr handler. 
> 
> Hi Bertil, nice to have you on this list.
> 
> > 
> > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > way to filter the handler's execution. I'd like to handle the documents
> > only if their URI or content matches specific conditions.
> 
> I will have a look at your patch, thanks in advance for your
> contribution. 
> 
> > 
> > For example, the document is handled only if its uri matches the
> > following regex:
> > 
> > http://www.awebsite.com/document-[0-9]*.htm
> > 
> > What's the best way to do that? Is it delegated to the handler's
> > implementation or is there a standard way?
> 
> Mingfai has this filter approach theoretically included in our next
> version. However right now we do not have a standard approach other then
> implementing the validation logic in e.g. the queue. The question is
> whether you want only to crawl the pages that are valid against your
> regex or the limitation is only for the handler. 
> 
> If it is only for the handler then it is maybe best to implement it in
> your worker. Something like:
> ...
> public void execute(Link link) throws DroidsException, IOException {
> 
> ...
> URI uri = link.getURI();
> Pattern pattern = Pattern.compile(PATTERN);
> Matcher matcher = pattern.matcher(uri);
> if (matcher.find()) {
>   droid.getHandlerFactory().handle(link.getURI(), entity);
> }
> ...}
> 
> 
> HTH
> 
> salu2
> 
> > 
> > Best regards,
> > 
> > Bertil Chapuis
> > 
> > 


RE: Customizable Solr Handle

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Fri, 2009-09-11 at 12:12 +0200, Bertil Chapuis wrote:
> I just had a look on the Droids architecture and I ask me if the Parser
> could not be considered as a Handler because in most handlers we will
> have to parse the content again. 

https://issues.apache.org/jira/browse/DROIDS-57

salu2

> 
> Doing this could lead to a simple generic filter mechanism. When
> executed, the Worker receive an object (Link, FileTask, etc) and for
> each Handlers test with the Filter(s) if the Handler should be executed
> or not.
> 
> filter.shouldExecute(Link, Handler){...}
> 
> What do you think about that? It could be a nice way to keep things
> simple and modular.
> 
> Best regards,
> 
> Bertil
> 
> 
> 
> On Wed, 2009-09-09 at 11:15 +0100, Tony Dietrich wrote:
> > Haven't got time atm to look at this myself, but there's a nice approach to this sort problem (of what to do with pages that (need to be)|(have been crawled) ) in the old websphinx package.
> > 
> > If I remember rightly, the package uses predicate classes (which can be standardised or sub-classed) and which return true/false in certain conditions, and methods in the crawler class which determine what actions are taken under which circumstances.
> > Ie 
> > public boolean shouldVisit(..){..}
> > public boolean shouldDownload(..){..}
> > public boolean shouldProcess(..){..}
> > with each method calling a declared predicate class (or chain of classes, depending on whether the implementation contains sub classed predicates.)
> > 
> > Perhaps a similar approach could be used for droids, since it very nicely provides a standards-acceptable, extensible approach to this sort of problem.
> > 
> > Perhaps overkill for Bertil's problem, but for future implementations .....
> > 
> > Tony
> > 
> > 
> > -----Original Message-----
> > From: Thorsten Scherler [mailto:thorsten.scherler.ext@juntadeandalucia.es] 
> > Sent: 09 September 2009 11:11
> > To: droids-dev@incubator.apache.org
> > Subject: Re: Customizable Solr Handle
> > 
> > On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > > Hello,
> > > 
> > > My name is Bertil Chapuis. I am using droids for a personal project and
> > > I am trying to create a more customizable solr handler. 
> > 
> > Hi Bertil, nice to have you on this list.
> > 
> > > 
> > > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > > way to filter the handler's execution. I'd like to handle the documents
> > > only if their URI or content matches specific conditions.
> > 
> > I will have a look at your patch, thanks in advance for your
> > contribution. 
> > 
> > > 
> > > For example, the document is handled only if its uri matches the
> > > following regex:
> > > 
> > > http://www.awebsite.com/document-[0-9]*.htm
> > > 
> > > What's the best way to do that? Is it delegated to the handler's
> > > implementation or is there a standard way?
> > 
> > Mingfai has this filter approach theoretically included in our next
> > version. However right now we do not have a standard approach other then
> > implementing the validation logic in e.g. the queue. The question is
> > whether you want only to crawl the pages that are valid against your
> > regex or the limitation is only for the handler. 
> > 
> > If it is only for the handler then it is maybe best to implement it in
> > your worker. Something like:
> > ...
> > public void execute(Link link) throws DroidsException, IOException {
> > 
> > ...
> > URI uri = link.getURI();
> > Pattern pattern = Pattern.compile(PATTERN);
> > Matcher matcher = pattern.matcher(uri);
> > if (matcher.find()) {
> >   droid.getHandlerFactory().handle(link.getURI(), entity);
> > }
> > ...}
> > 
> > 
> > HTH
> > 
> > salu2
> > 
> > > 
> > > Best regards,
> > > 
> > > Bertil Chapuis
> > > 
> > > 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





RE: Customizable Solr Handle

Posted by Bertil Chapuis <co...@bertil.ch>.
I just had a look on the Droids architecture and I ask me if the Parser
could not be considered as a Handler because in most handlers we will
have to parse the content again. 

Doing this could lead to a simple generic filter mechanism. When
executed, the Worker receive an object (Link, FileTask, etc) and for
each Handlers test with the Filter(s) if the Handler should be executed
or not.

filter.shouldExecute(Link, Handler){...}

What do you think about that? It could be a nice way to keep things
simple and modular.

Best regards,

Bertil



On Wed, 2009-09-09 at 11:15 +0100, Tony Dietrich wrote:
> Haven't got time atm to look at this myself, but there's a nice approach to this sort problem (of what to do with pages that (need to be)|(have been crawled) ) in the old websphinx package.
> 
> If I remember rightly, the package uses predicate classes (which can be standardised or sub-classed) and which return true/false in certain conditions, and methods in the crawler class which determine what actions are taken under which circumstances.
> Ie 
> public boolean shouldVisit(..){..}
> public boolean shouldDownload(..){..}
> public boolean shouldProcess(..){..}
> with each method calling a declared predicate class (or chain of classes, depending on whether the implementation contains sub classed predicates.)
> 
> Perhaps a similar approach could be used for droids, since it very nicely provides a standards-acceptable, extensible approach to this sort of problem.
> 
> Perhaps overkill for Bertil's problem, but for future implementations .....
> 
> Tony
> 
> 
> -----Original Message-----
> From: Thorsten Scherler [mailto:thorsten.scherler.ext@juntadeandalucia.es] 
> Sent: 09 September 2009 11:11
> To: droids-dev@incubator.apache.org
> Subject: Re: Customizable Solr Handle
> 
> On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> > Hello,
> > 
> > My name is Bertil Chapuis. I am using droids for a personal project and
> > I am trying to create a more customizable solr handler. 
> 
> Hi Bertil, nice to have you on this list.
> 
> > 
> > I posted a ticket with my code (DROIDS-62). However, I am looking for a
> > way to filter the handler's execution. I'd like to handle the documents
> > only if their URI or content matches specific conditions.
> 
> I will have a look at your patch, thanks in advance for your
> contribution. 
> 
> > 
> > For example, the document is handled only if its uri matches the
> > following regex:
> > 
> > http://www.awebsite.com/document-[0-9]*.htm
> > 
> > What's the best way to do that? Is it delegated to the handler's
> > implementation or is there a standard way?
> 
> Mingfai has this filter approach theoretically included in our next
> version. However right now we do not have a standard approach other then
> implementing the validation logic in e.g. the queue. The question is
> whether you want only to crawl the pages that are valid against your
> regex or the limitation is only for the handler. 
> 
> If it is only for the handler then it is maybe best to implement it in
> your worker. Something like:
> ...
> public void execute(Link link) throws DroidsException, IOException {
> 
> ...
> URI uri = link.getURI();
> Pattern pattern = Pattern.compile(PATTERN);
> Matcher matcher = pattern.matcher(uri);
> if (matcher.find()) {
>   droid.getHandlerFactory().handle(link.getURI(), entity);
> }
> ...}
> 
> 
> HTH
> 
> salu2
> 
> > 
> > Best regards,
> > 
> > Bertil Chapuis
> > 
> > 


RE: Customizable Solr Handle

Posted by Tony Dietrich <to...@dietrich.org.uk>.
Haven't got time atm to look at this myself, but there's a nice approach to this sort problem (of what to do with pages that (need to be)|(have been crawled) ) in the old websphinx package.

If I remember rightly, the package uses predicate classes (which can be standardised or sub-classed) and which return true/false in certain conditions, and methods in the crawler class which determine what actions are taken under which circumstances.
Ie 
public boolean shouldVisit(..){..}
public boolean shouldDownload(..){..}
public boolean shouldProcess(..){..}
with each method calling a declared predicate class (or chain of classes, depending on whether the implementation contains sub classed predicates.)

Perhaps a similar approach could be used for droids, since it very nicely provides a standards-acceptable, extensible approach to this sort of problem.

Perhaps overkill for Bertil's problem, but for future implementations .....

Tony


-----Original Message-----
From: Thorsten Scherler [mailto:thorsten.scherler.ext@juntadeandalucia.es] 
Sent: 09 September 2009 11:11
To: droids-dev@incubator.apache.org
Subject: Re: Customizable Solr Handle

On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> Hello,
> 
> My name is Bertil Chapuis. I am using droids for a personal project and
> I am trying to create a more customizable solr handler. 

Hi Bertil, nice to have you on this list.

> 
> I posted a ticket with my code (DROIDS-62). However, I am looking for a
> way to filter the handler's execution. I'd like to handle the documents
> only if their URI or content matches specific conditions.

I will have a look at your patch, thanks in advance for your
contribution. 

> 
> For example, the document is handled only if its uri matches the
> following regex:
> 
> http://www.awebsite.com/document-[0-9]*.htm
> 
> What's the best way to do that? Is it delegated to the handler's
> implementation or is there a standard way?

Mingfai has this filter approach theoretically included in our next
version. However right now we do not have a standard approach other then
implementing the validation logic in e.g. the queue. The question is
whether you want only to crawl the pages that are valid against your
regex or the limitation is only for the handler. 

If it is only for the handler then it is maybe best to implement it in
your worker. Something like:
...
public void execute(Link link) throws DroidsException, IOException {

...
URI uri = link.getURI();
Pattern pattern = Pattern.compile(PATTERN);
Matcher matcher = pattern.matcher(uri);
if (matcher.find()) {
  droid.getHandlerFactory().handle(link.getURI(), entity);
}
...}


HTH

salu2

> 
> Best regards,
> 
> Bertil Chapuis
> 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





Re: Customizable Solr Handle

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Wed, 2009-09-09 at 10:38 +0200, Bertil Chapuis wrote:
> Hello,
> 
> My name is Bertil Chapuis. I am using droids for a personal project and
> I am trying to create a more customizable solr handler. 

Hi Bertil, nice to have you on this list.

> 
> I posted a ticket with my code (DROIDS-62). However, I am looking for a
> way to filter the handler's execution. I'd like to handle the documents
> only if their URI or content matches specific conditions.

I will have a look at your patch, thanks in advance for your
contribution. 

> 
> For example, the document is handled only if its uri matches the
> following regex:
> 
> http://www.awebsite.com/document-[0-9]*.htm
> 
> What's the best way to do that? Is it delegated to the handler's
> implementation or is there a standard way?

Mingfai has this filter approach theoretically included in our next
version. However right now we do not have a standard approach other then
implementing the validation logic in e.g. the queue. The question is
whether you want only to crawl the pages that are valid against your
regex or the limitation is only for the handler. 

If it is only for the handler then it is maybe best to implement it in
your worker. Something like:
...
public void execute(Link link) throws DroidsException, IOException {

...
URI uri = link.getURI();
Pattern pattern = Pattern.compile(PATTERN);
Matcher matcher = pattern.matcher(uri);
if (matcher.find()) {
  droid.getHandlerFactory().handle(link.getURI(), entity);
}
...}


HTH

salu2

> 
> Best regards,
> 
> Bertil Chapuis
> 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)