Hi, I guess that 'a' is a stop-word for Lucene (very common English word) and is ignored, but I'm not sure. You should check with Lucene.
Regards, Thomas On Sat, Oct 3, 2009 at 12:22 PM, Buzz <[email protected]> wrote: > > Hi > > I'm not too sure whether this problem is due to my inexperience with > lucene or whether there is an issue with H2. > > I have a simple create table, insert strings, search for words with > wildcard. > > The data: > a > ab > abc > abcd > abcde > abb > acc > add > aee > > If I do a search for 'ab*' (limit 5) then I get ab .. abb > If I do a search for 'ac*' (limit 5) then I get acc > > However, if I do a search for 'a*' (limit 5) then I get ab .. abb -> > ie no 'a' > > Is my seach expression wrong? > > Nick > > > Class.forName("org.h2.Driver"); > > > Connection conn = DriverManager.getConnection > ("jdbc:h2:file:db_test/db_test", "sa", ""); > Statement stat = conn.createStatement(); > > stat.execute("CREATE ALIAS IF NOT EXISTS FTL_INIT FOR > \"org.h2.fulltext.FullTextLucene.init\""); > stat.execute("CALL FTL_INIT()"); > stat.execute("CREATE TABLE TEST_DB(ID INT PRIMARY KEY > AUTO_INCREMENT, KEY INT, WORD VARCHAR, TYPE CHAR, DESC VARCHAR)"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('a')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('ab')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('abc')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('abcd')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('abcde')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('abb')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('acc')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('add')"); > stat.execute("INSERT INTO TEST_DB (WORD) VALUES('aee')"); > stat.execute("CALL FTL_CREATE_INDEX('PUBLIC', 'TEST_DB', > NULL)"); > > ResultSet rs = stat.executeQuery("SELECT T.* FROM > FTL_SEARCH_DATA('a*', 5, 0) FT, TEST_DB T WHERE FT.TABLE='TEST_DB' AND > T.ID=FT.KEYS[0]"); > > while (rs.next()) { > String word = rs.getString("WORD"); > System.out.println("word " + word); > } > > conn.close(); > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/h2-database?hl=en -~----------~----~----~----~------~----~------~--~---
