Exact search on a long text index

Jun 19, 2013 at 10:14 AM
Edited Jun 19, 2013 at 3:19 PM
Hello everyone,

I'm trying to search in a longtext index and have an exact match on the search value.
The index contains only file paths, so every record starts with a "/".
When I'm searching for "/", I expect to find only one or two entries. But depending on the grBits I put, I either get 0 results or every entries in the table.
What is the correct way to do this ?

Thanks in advance for your time,
Jun 20, 2013 at 10:32 AM
Here is a sample of the code I use for searching:
using (var session = new Session(esentInstance))
                JET_DBID dbid;

                Api.JetAttachDatabase(session, databaseName, AttachDatabaseGrbit.None);
                Api.JetOpenDatabase(session, databaseName, null, out dbid, OpenDatabaseGrbit.None);

                using (var table = new Table(session, dbid, "Files", OpenTableGrbit.None))

                    IDictionary<string, JET_COLUMNID> columnids = Api.GetColumnDictionary(session, table);

                    Api.JetSetCurrentIndex(session, table, indexName);

                    Api.MakeKey(session, table, value, Encoding.Unicode, MakeKeyGrbit.NewKey);
                    if (Api.TrySeek(session, table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange) && Api.TryMoveFirst(session, table))
                            File vf = new File();

                            vf.Id = Api.RetrieveColumnAsString(session, table, columnids["id"]);
                            vf.fileName = Api.RetrieveColumnAsString(session, table, columnids["fileName"]);
                            vf.size = Api.RetrieveColumnAsInt64(session, table, columnids["size"]).Value;
                            vf.isFolder = Api.RetrieveColumnAsBoolean(session, table, columnids["isFolder"]).Value;
                            vf.isOffline = Api.RetrieveColumnAsBoolean(session, table, columnids["isOffline"]).Value;
                            vf.isWebFile = Api.RetrieveColumnAsBoolean(session, table, columnids["isWebFile"]).Value;
                            vf.thumbnail = Api.RetrieveColumn(session, table, columnids["thumbnail"]);
                            vf.thumbnailMimeType = Api.RetrieveColumnAsString(session, table, columnids["thumbnailMimeType"]);
                            vf.mimeType = Api.RetrieveColumnAsString(session, table, columnids["mimeType"]);
                            vf.offlinePath = Api.RetrieveColumnAsString(session, table, columnids["offlinePath"]);
                            vf.parentId = Api.RetrieveColumnAsString(session, table, columnids["parentId"]);

                            [...] Various stuff

                        while (Api.TryMoveNext(session, table));
I have an index on parentId:
                indexDef = "+parentId\0\0";
                Api.JetCreateIndex(sesid, tableid, "parentId", CreateIndexGrbit.None, indexDef, indexDef.Length, 100);
The issue I'm facing is when I search the index for a parentId called "/".
Jul 22, 2013 at 7:36 PM
Did you find a solution for this?

One possibility is that null-termination is tripping you up. How did you insert the strings? If you have "/" (with no null termination) stored in the database, but are searching for "/\0", than an Equals match will not find anything. Another possibility is that the ANSI/Unicode encoding is confused. What does your indexDef look like?

Is this working for longer strings (e.g. "/users/doctorwho")? Or is it only broken for single-character strings?