суббота, 6 августа 2011 г.

Alfresco: strong text search with wildcard using lucene

My new problem is not very difficult, but have interesting solution (I think :)). For example we have four objects in our alfresco repository that have next titles:
  • James John
  • Li Joan
  • Johan Jazz
  • Bill

For get all objects that begins from 'Joh', I use the next query:
+TYPE:"my:object" +@cm\:title:"joh*"

The result of the query:
  • James John
  • Johan Jazz
  • Li Joan

'Joan' doesn't contain 'joh' in title. For solve that I modify my query:
+TYPE:"my:object" +@cm\:title:"[joh*]"

This query returns the right result:
  • James John
  • Johan Jazz

You can find more lucene tricks in wonderful book that called: "Lucene in Action" :)

вторник, 2 августа 2011 г.

Quartz: running jobs sequentially

To initialize (import dictionaries, create system users and roles, etc) our system we use quartz. But yesterday after I've created new job I saw that my new job depends on other jobs. Still I don't get how can I create dependencies over jobs and I think that the usage of dependencies in jobs is an ugly solution. The solution is simply to run jobs sequentially - one by one. But I couldn't find fast way to do that. One job runs in one thread and if I set threads count to 1, then I solve my problem. Here is the code to do that:

Properties schedProps = new Properties();
schedProps.setProperty(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName());
schedProps.setProperty(StdSchedulerFactory.PROP_THREAD_POOL_PREFIX + ".threadCount", "1");
StdSchedulerFactory factory = new StdSchedulerFactory(schedProps);
Scheduler initScheduler = factory.getScheduler();
Now all jobs in initScheduler will run one by one.
It's simple and actually work :)

Most popular

Authors