SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye

Welcome, Guest
Guest Settings
Help

Compass Support Forums » Compass » Compass Users

Thread: Can’t make compass work with OSEM mapping

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


Permlink Replies: 4 - Pages: 1 - Last Post: Jul 24, 2010 10:36 AM Last Post By: Hussi
Gorunus

Posts: 9
Registered: 7/20/10
Can’t make compass work with OSEM mapping
Posted: Jul 20, 2010 5:47 AM
 
  Click to reply to this thread Reply
Hello!

I’m beginning with Compass and I cannot manage to get it work!
I use OSEM Mapping with annotations @Searchable, @SearchableId and @SearchableProperty on one Table => Identifications.java
I do not use any XML file! Only Compass anotations in my POJOs

I execute this code and I always get 0 hits on sizze!!!

CompassConfiguration conf = new CompassConfiguration().setConnection("/temp/index");
conf.addClass(Identifications.class);
Compass compass = conf.buildCompass();
CompassSession session = compass.openSession();
 
CompassTransaction tx = null;
try {
     tx = session.beginTransaction();
     CompassHits hits = session.find("dmin"); //to fin "Administrator or administrator
     int sizze = hits.length(); //this is always 0!!!
     tx.commit();
} 
catch (CompassException ce) {
     if (tx != null) tx.rollback();
} 
finally {
     session.close();
}

When does Compass index all database that maps @Searchable* anotations?
A assumed that conf.buildCompass(); is already indexing my data!!!
Am I wrong?
I did not find a lot of tutorials on Compass with OSEM!

Edited by: Bogdan on Jul 20, 2010 3:30 PM

mihwang

Posts: 14
Registered: 7/13/10
Re: Can’t make compass work with OSEM mapping
Posted: Jul 20, 2010 5:32 PM   in response to: Gorunus in response to: Gorunus
Helpful
  Click to reply to this thread Reply
I don't believe compass is automatically indexing your data.

Is your data is in a database? If it is, you are most likely going to want to use a GPS device (Check out chapters 15-23 in the reference manual). A GPS device will basically hook up to a data source and "navigate" it for you when you call the index() function on the GPS that controls it - so it will automatically index for you based on what mappings you have provided. Otherwise you are going to have to build your own index programmatically like the examples in chapter 12.

For convenience, here is a link to the reference manual: http://www.compass-project.org/docs/2.2.0/reference/html/

Let me know if this helps at all or if you have more questions.
Gorunus

Posts: 9
Registered: 7/20/10
Re: Can’t make compass work with OSEM mapping
Posted: Jul 21, 2010 5:22 AM   in response to: Gorunus in response to: Gorunus
 
  Click to reply to this thread Reply
Thank you! Done it!
I use a PostgreSql database with Hibernate POJOs. I made myself a CompassGpsDevice as folows:

//compass init
//...
SessionFactory sessionFactory = ((HibernateEntityManagerFactory)managerFactory).getSessionFactory();
CompassGps gps = new SingleCompassGps(compass);
CompassGpsDevice device = new Hibernate3GpsDevice("hibernate", sessionFactory);
gps.addGpsDevice(device);
 
gps.start();
gps.index();

All i figured out is that... after the index is beeing created... my search
CompassHits hits = session.find("ministrat");
desn't match my "Administrator" record line. I am forced to add "*" at my String to match it :
CompassHits hits = session.find("*ministrat*");
mihwang

Posts: 14
Registered: 7/13/10
Re: Can’t make compass work with OSEM mapping
Posted: Jul 21, 2010 10:10 AM   in response to: Gorunus in response to: Gorunus
 
  Click to reply to this thread Reply
Compass uses the same search query string syntax as Lucene, so you will have to add the wildcard modifiers in order to search "ministrat" and return "administrator."

Check out the Query Parser Syntax here and also Chapter 12.5 of the Compass reference manual:
http://lucene.apache.org/java/2_4_0/queryparsersyntax.html
Hussi

Posts: 1
Registered: 7/24/10
Re: Can’t make compass work with OSEM mapping
Posted: Jul 24, 2010 10:36 AM   in response to: Gorunus in response to: Gorunus
 
  Click to reply to this thread Reply
[url=http://www.intensevents.com]vintage china hire[/url]
Legend
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