Full text search, lightweight data management

Tutorials with advanced 'difficulty' and more Lines of Code.

Full text search, lightweight data management

Postby tedk » Tue Jan 27, 2009 5:25 am

The new Perst 4.0 open source, object-oriented embedded database for Java includes native full-text search capability in its edition for Android, and has added a sample search engine application for contact data residing on Android-based mobile phones.

To provide search, the database stores an inverse index of keywords, with parsing and stemming of indexed text performed either by user-defined code or by Perst's default simple parser and stemmer. The feature supports logical operators and calculates relevance of search results to a query.

The new sample application, called ContactsIndex, stores and indexes contact information, and could be extended to provide search capabilities for PDF, word processing, HTML and other stored files. The example application is included with complete source code in the Perst 4.0 for Java distribution, available for free download at http://www.mcobject.com/perst_eval

Also new in Perst 4.0 for Android: support for non-native objects, which expands the scope of the embedded database to benefit a larger variety of application types.

You can find out more about Perst 4.0 at:

http://www.mcobject.com/perst_v4_for_mobile_phones



Image
Ted Kenney
McObject
tedk
Freshman
Freshman
 
Posts: 5
Joined: Sun Dec 30, 2007 2:42 am
Location: Issaquah, WA

Top

Postby Anbou » Thu Feb 04, 2010 12:34 am

Hi Tedk,

I try to make a simple project with Perst to Add, insert and select object with a Button. But when I close application I can't get object stored in database. The application fail with exception "Failed to locate com.android.test.User" ClassNotFoundException: in loader dalvik.system.PathClassLoad".

User.class
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3. public class User extends Persistent {
  4.  
  5.         public String lastName;
  6.  
  7.         public String firstName;
  8.  
  9.  
  10.  
  11.         public User(String name, String firstname) {
  12.  
  13.                 super();
  14.  
  15.                 this.lastName = name;
  16.  
  17.                 this.firstName = firstname;
  18.  
  19.         }
  20.  
  21.  
  22.  
  23.         public User() {
  24.  
  25.         }
  26.  
  27.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Method
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. public Storage openDatabase(Context c) {
  5.  
  6.                 try {
  7.  
  8.                         db = StorageFactory.getInstance().createStorage();
  9.  
  10.                         db.setProperty("perst.string.encoding", "UTF-8"); // use UTF-8
  11.  
  12.                         db.open(getDataBasePath(), PAGE_POOL_SIZE); //<<<<-----FAIL HERE
  13.  
  14.                                 root = (Indices) db.getRoot();
  15.  
  16.                                 if (root == null) {  
  17.  
  18.                                    root = new Indices(db);
  19.  
  20.                                    root.strIndex = db.<User> createFieldIndex(User.class, new String[] {
  21.  
  22.                                 "lastName", "firstName" }, true);
  23.  
  24.                                         db.setRoot(root);
  25.  
  26.                                 }
  27.  
  28.                 } catch (Throwable e) {
  29.  
  30.                         Log.e("openDatabase", e.toString());
  31.  
  32.                         return null;
  33.  
  34.                 }
  35.  
  36.                 return db;
  37.  
  38.         }
  39.  
  40. public void showAllUsers(Context c) {            
  41.  
  42.                 openDatabase(c);
  43.  
  44.                 Key lastName = new Key((new Object[] { "User 5" }));
  45.  
  46.                 Iterator<User> iterator = root.intIndex.iterator(lastName, lastName,
  47.  
  48.                                 Index.ASCENT_ORDER);
  49.  
  50.                 while (iterator.hasNext()) {
  51.  
  52.                         User p = iterator.next();
  53.  
  54.                         Log.v("User Found", p.toString());
  55.  
  56.                 }
  57.  
  58.         }
  59.  
  60.  
  61.  
  62. public boolean insert(Context c, List<User> obj) {
  63.  
  64.                 openDatabase(c);
  65.  
  66.                 FieldIndex<User> intIndex = root.intIndex;
  67.  
  68.                 for (User user : obj) {
  69.  
  70.                         intIndex.put(user);  
  71.  
  72.                         Log.v("Add USER", user.toString());
  73.  
  74.                 }
  75.  
  76.                 db.commit();  
  77.  
  78.                 return true;
  79.  
  80.         }
  81.  
  82.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


Otherwise can someone show me a simple project to add delete et select object with Perst who work fine with android.

Note : I have tested "testIndex" project but in this project the object has been stored after selected all and last deleted it. And me I would like stored object, close the application ,re-open and select some object.

Regards,
A.Boulani
Anbou
Freshman
Freshman
 
Posts: 2
Joined: Thu Feb 04, 2010 12:26 am

Full text search, lightweight data management

Postby tedk » Thu Feb 04, 2010 12:54 am

Hi,

We'd be happy to help you get the answer to your question. The best resource is to go to http://forums.mcobject.com/ and ask your question in the Perst forum.

Regards,



Tedk
Ted Kenney
McObject
tedk
Freshman
Freshman
 
Posts: 5
Joined: Sun Dec 30, 2007 2:42 am
Location: Issaquah, WA

Postby Anbou » Thu Feb 04, 2010 1:16 am

Thank for your anwser ,I know this forum but I don't have permission to start a topic or answer , so I try here and I hope that some people come here. I have been send an e-mail to the administrator and now "I'm waiting".
Anbou
Freshman
Freshman
 
Posts: 2
Joined: Thu Feb 04, 2010 12:26 am

Postby jonw » Thu Feb 11, 2010 5:21 pm

How is this different from the Quick Search Box native to 1.6?

http://developer.android.com/resources/ ... s/qsb.html
Starting with Android 1.6, the platform includes support for Quick Search Box (QSB), a powerful, system-wide search framework. Quick Search Box makes it possible for users to quickly and easily find what they're looking for, both on their devices and on the web. It suggests content on your device as you type, like apps, contacts, browser history, and music. It also offers results from the web search suggestions, local business listings, and other info from Google, such as stock quotes, weather, and flight status. All of this is available right from the home screen, by tapping on Quick Search Box.


Also app developers can make their content visible to this service.
Not trolling honest, Perst sounds like some cool tech, just curious :)
User avatar
jonw
Junior Developer
Junior Developer
 
Posts: 24
Joined: Wed Feb 10, 2010 9:00 pm
Location: London

Top

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests