Main Overview Wiki Issues Forum Build Fisheye

Welcome, Guest
Guest Settings

Compass Support Forums » Compass » Compass Users

Thread: JDBC datasource : automatic indexing ????

This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Permlink Replies: 7 - Pages: 1 - Last Post: Nov 18, 2011 1:54 AM Last Post By: lorna lee
Stefaan Somers

Posts: 7
Registered: 10/13/09
JDBC datasource : automatic indexing ????
Posted: Oct 13, 2009 4:47 AM
  Click to reply to this thread Reply

I'm probably a newbie, and that's why I'm missing something out.

I've the following script, which I pause in Eclipse before getting the results. In the mean time I update the table, and wait some minutes. I would expect that the index is updated automatically, and that my result would also return the latest updates I've done. Apparently this is not the case. Or do I have to call each time gps.index (which is replacing the index in total instead of updating)

Any help would be most welcome.

import org.compass.core.Compass;
import org.compass.core.CompassHit;
import org.compass.core.CompassHits;
import org.compass.core.CompassSession;
import org.compass.core.CompassTransaction;
import org.compass.core.config.CompassConfiguration;
import org.compass.core.config.CompassEnvironment;
import org.compass.gps.device.jdbc.ResultSetJdbcGpsDevice;
import org.compass.gps.device.jdbc.ResultSetResourceMappingResolver;
import org.compass.gps.device.jdbc.mapping.IdColumnToPropertyMapping;
import org.compass.gps.device.jdbc.mapping.TableToResourceMapping;
import org.compass.gps.device.jdbc.mapping.VersionColumnMapping;
import org.compass.gps.impl.SingleCompassGps;
import org.postgresql.jdbc2.optional.SimpleDataSource;

public class TestLuceneIndex {

* @param args

public static void main(String[] args) {
ResultSetJdbcGpsDevice gpsDevice;
SingleCompassGps gps;
Compass compass;

TableToResourceMapping parentMapping = new TableToResourceMapping("PDC_PRODUCT_", "PRODUCT");
parentMapping.addIdMapping(new IdColumnToPropertyMapping("ID_", "ID"));
parentMapping.addVersionMapping(new VersionColumnMapping("modified_"));

TableToResourceMapping childMapping = new TableToResourceMapping("PDC_DOELGROEP_", "DOELGROEP");
childMapping.addIdMapping(new IdColumnToPropertyMapping("ID_", "ID"));
childMapping.addVersionMapping(new VersionColumnMapping("modifed_"));
System.out.println("Query : " + childMapping.getVersionQuery());

SimpleDataSource dataSource = new SimpleDataSource();


CompassConfiguration conf = new CompassConfiguration().setSetting(CompassEnvironment.CONNECTION,

conf.addMappingResolver(new ResultSetResourceMappingResolver(parentMapping, dataSource));
conf.addMappingResolver(new ResultSetResourceMappingResolver(childMapping, dataSource));

// build the mirror compass instance
compass = conf.buildCompass();

gps = new SingleCompassGps(compass);

gpsDevice = new ResultSetJdbcGpsDevice();


CompassSession session = compass.openSession();
CompassTransaction tr = session.beginTransaction();
CompassHits hits = session.find("product");

CompassHit[] detachedHits = hits.detach(0, 20).getHits();
System.out.println("Number of hits " + detachedHits.length);
// outside of a transaction (maybe in a view technology)
for (int i = 0; i < detachedHits.length; i++) {
// this will return the first fragment

System.out.println(detachedHits[i].getResource().getValue("NAME") + " - score : " + detachedHits[i].getScore() );





private static void runInfinitive() {
while (true) {




Posts: 5
Registered: 10/8/09
Re: JDBC datasource : automatic indexing ????
Posted: Oct 16, 2009 1:17 AM   in response to: Stefaan Somers in response to: Stefaan Somers
  Click to reply to this thread Reply
ResultSetJdbcGpsDevice does active mirroring... That means you have to explicitly perform the mirroring...

Do the "gpsDevice.index()" only once and each time before you search perform "gpsDevice.performMirroring()"

If you index each time, The whole table will get indexed again. If the table data is more, it will take more time.

but performMirrorring will check in the database and index only newly added or updated data.
Stefaan Somers

Posts: 7
Registered: 10/13/09
Re: JDBC datasource : automatic indexing ????
Posted: Oct 20, 2009 3:35 AM   in response to: Arun in response to: Arun
  Click to reply to this thread Reply

I tried your alternative, but unfortunateley the index doesn't get updated. Any clue what I may be missing??

Posts: 1
Registered: 11/10/09
Re: JDBC datasource : automatic indexing ????
Posted: Nov 10, 2009 6:35 AM   in response to: Stefaan Somers in response to: Stefaan Somers
  Click to reply to this thread Reply
I'm trying to do the same thing here while reading the docs and I'm confused with these "snapshots" that are created during mirroring. So I guess you need to add this to enable mirroring:

gpsDevice.setSnapshotPersister(new FSJdbcSnapshotPersister("target/testindex/snapshot"));

Not sure though...

Posts: 411
Registered: 8/23/11
Re: JDBC datasource : automatic indexing ????
Posted: Aug 23, 2011 9:34 PM   in response to: Stefaan Somers in response to: Stefaan Somers
  Click to reply to this thread Reply
Welcome to louis vuitton online! Here at our online shop, we enable you to select as many styles louis vuitton bags as you can at greatly discounted prices. Established in 2006, We have already landed so many returning customers from louis vuitton outlet. We have been known for the authentic quality of our items,such as louis vuitton belts and louis vuitton purses unsurpassed customer service, rapid delivery, unique prices and so on and so forth. What we did, are doing and will do is only to make our esteemed customers consume those world-renowned luxury designer merchandise with peace of mind. So we sincerely hope that you could be our next returning customer. We are confident that you will be quite satisfied with everything we offer here. Wish you a very good shopping louis vuitton store!

Posts: 25
Registered: 10/25/11
Re: JDBC datasource : automatic indexing ????
Posted: Oct 25, 2011 10:16 PM   in response to: Stefaan Somers in response to: Stefaan Somers
  Click to reply to this thread Reply
Besides famous people's individual preferences of watches,usually, there are some methods for manufacturers to promote their products. The most Replica Versace ne indicative. Give him a heartfelt belt gift, which helps to build him an image of dignity and express your deep love. Men's Genuine Leather Au Tank were passed through people's minds at the mention of Swiss.You can find a wide variety of replica Swiss watch online. It is easy for you to gucci bags watch makers. And it also produces classic timepieces that are precious and worth to own.More and more people choose to buy an IWC watch online for both wea swiss breitling common way is inviting a number of proper celebrities as their brand spokesmen.Oscar actor George Clooney has become a member of Omega's partners since 2007. swiss rolex le charge. Assume it is of superior quality and fantastic functions, its appeal will probably be enhanced. Swiss replica watches do have a replica watches logy. We have displayed three pattern. The articles are greatly in demand and they are selling at low price.Since came into being in 1829 , glasses have replica watches uk original ideal to provide essential crafts. Water-proof feature, quake and magnetic prevention with original IWC Portuguese design swiss rolex be intrigued by a particular brand; People who are fashion queens are more often than not drawn to the latest fashion trends associated with pur replica louis vuitton ition to attire along with a complete look. Among other jewelry options, necklaces always act as a focal point to an appearance. These can be used gucci replica handbags daunting for most of us. Fashion changes from time to time. This article helps you go shopping without breaking your bank.Being the most swiss replica watches perfect pair for your outfit. Cute short boots are the way to go. You will stand out with your fashionable style.You should pay attention to Replica Hamilton not mature for young people and childish for grown-ups.These three pairs of Chanel shoes may be the most proper shoes for Valentine's gifts. Do swiss replica ED Hardy Cap is famous not only for the fashion, but also for its high quality. It is made of porous materials, such as a combination of a rolex replica rs were embroidered with crochet flowers. They are looks very beautiful and comfortable. If your beloved is a ballet dancer, she must love this Replica Graham ars last week. Now, we see this rich man showcasing a $1.5 million dollar diamond encrusted Chopard watch.. It is said that this guy love everythi Replica Movado simple way. They are appropriate for everyday life too!Usually, a famous bag manufacturer will launch a new series of bags when a new season i gucci replica handbags deep sea, the divers use the mixture of helium and oxygen so as to reduce the phenomenon of being paralytic and buffer the time of r GST / Aquatimer of hardship in his early years that he has a deep understanding of the very dynamic in life which makes his design vibrant and attracting.In t replica louis vuitton Mobile plays a more and more important role in our daily life. To achieve its communication function, cell phones have to receive and send powerful louis vuitton handbags
Guru: 2001 + pts
Expert: 501 - 2000 pts
Super-star: 101 - 500 pts
Assistant: 51 - 100 pts
Participant: 0 - 50 pts
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums