This project has moved and is read-only. For the latest updates, please go here.

How can I search strings with "EndsWith" condtion.

Nov 21, 2013 at 8:06 AM
I'm trying to search strings for an Unicode column with Api.MakeKey() and Api.TrySeek().

I can search "StartsWith" operation with next code.
Api.MakeKey(sess, tbl, (string)val, encode, MakeKeyGrbit.NewKey);
Api.TrySeek(sess, tbl, SeekGrbit.SeekGE);

Api.MakeKey(sess, tbl, (string)val, encode, MakeKeyGrbit.NewKey | MakeKeyGrbit.SubStrLimit);
//MakeKeyGrbit.PartialColumnEndLimit can be used insted of MakeKeyGrbit.SubStrLimit

Api.JetSetIndexRange(sess, tbl, SetIndexRangeGrbit.RangeInclusive | SetIndexRangeGrbit.RangeUpperLimit);
Is there any way to perform "EndsWith" postfix search operation?
Dec 2, 2013 at 3:47 AM
Unfortunately, there is no easy way to do it. ESE indexes things by using sorted normalized keys. Think of trying to look up all first names of 'Michael' in a typical white pages phone book. There is just no fast way to do it.

In the interest of full disclosure:
If you create a 'Tuple Index' you may be able to do it quickly. See the documentation on JET_TUPLELIMITS for some discussion.

But to be honest, it's not well-tested, and creates a lot of disk overhead in order to pre-create the index entries. If you try it out, prepare to be disappointed. I don't recommend it.